Closed Bug 373322 Opened 17 years ago Closed 16 years ago

When a single Form element is alone under the form tag and is removed by scripting, doesnt get removed from the <element-name> based properties under the form object

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 307415

People

(Reporter: manickam79, Unassigned)

Details

Attachments

(1 file)

1.94 KB, application/octet-stream
Details
User-Agent:       Mozilla/5.0 (X11; U; Linux i386; en-US; rv:1.8.1) Gecko/20061010 FreeBSD/i386 Firefox/2.0
Build Identifier: Mozilla/5.0 (X11; U; Linux i386; en-US; rv:1.8.1) Gecko/20061010 FreeBSD/i386 Firefox/2.0

If we have a form with a single input tag element inside it & try to remove it, it doesnt remove the <input-tag-name> property under the form object, even though the elements property doesnt show the input tag.

The expected behaviour is to remove it altogether from the form object..so that any later check for that specific input-tag based on <form-name>.<input-tag-name> property returns undefined.

Reproducible: Always

Steps to Reproduce:
<?php
	var_dump( $_REQUEST );
?>

<script type='text/javascript'>

function additem( index )
{
}

var i = 1;
function genNewsCollRow(  )//index only used as idname
{
	strHTML = '<tr id="tr_id_' + i + '" ><td>Hello ' + i + i + i  + '</td><td><input type=hidden name=inp_ids value=inp_' + i + ' /></td></tr>';
	i++;
	return strHTML;
}

function myalert()
{
	var objTable = document.getElementById( 'NewsCollection' );
	alert( objTable.innerHTML );
	if( typeof document.savecollection == 'undefined' || typeof document.savecollection.inp_ids == 'undefined' )
	{
		alert( 'undefined savecollection object ');
	}
	else
	{
		objids = document.savecollection.inp_ids;
		if( typeof document.savecollection.inp_ids.length == 'undefined' )
		{
			alert( 'Element = ' + objids.value );
		}
		else
		{
			for( i=0; i< objids.length; i++)
			{
				alert( 'Element =' + objids[i].value );
			}
		}
	}
}

function saveColl()
{
	var strHTML = '';
	var objTable = document.getElementById( 'NewsCollection' );

	strHTML = strHTML + genNewsCollRow( );
	objTable.innerHTML = objTable.innerHTML + strHTML;
	
	var objids = document.savecollection.inp_ids;
	var i;

	alert( 'Before 1st Removal' );
	myalert();

	var objtr1 = document.getElementById( 'tr_id_1' );

	objtr1 = objTable.removeChild( objtr1 );
	alert( 'After 1st Removal' );
	myalert();

	objTable.appendChild( objtr1 );

	alert( 'Before 2nd Removal' );
	myalert();

	objtr1 = document.getElementById( 'tr_id_1' );
	objtr1 = objTable.removeChild( objtr1 );

	alert( 'After 2st Removal' );
	myalert();

	document.savecollection.submit();
}


</script>

<form name=savecollection >
<table width="80%" style="border: 2px groove blue; background-color: lightblue" align=center>
<tbody id="NewsCollection">
</tbody>
</table>
<table width="80%" style="border: 2px groove blue; background-color: lightblue" align=center>
<tr><td align=center ><input type=submit name=saveCollList value='Save' onclick='saveColl(); return false;' /></td></tr>
</table>
</form>

Actual Results:  
savecollection.inp_ids is still accessible & valid

Expected Results:  
savecollection.inp_ids should return undefined.

Looks like related to bug 373200
Attached file Sample TestScript
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: