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

RESOLVED DUPLICATE of bug 307415

Status

()

Firefox
General
RESOLVED DUPLICATE of bug 307415
11 years ago
10 years ago

People

(Reporter: manickam, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

1.94 KB, application/octet-stream
Details
(Reporter)

Description

11 years ago
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
(Reporter)

Comment 1

11 years ago
Created attachment 257972 [details]
Sample TestScript

Updated

10 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 307415
You need to log in before you can comment on or make changes to this bug.