...

View Full Version : problems with forms and dynamic input elements



LottaLava
01-09-2004, 06:59 PM
Hello folks, could someone tell me why a dynamic input text connot be accessed from a form objet? For example:

function test( )
{
var frm = document.forms[ 0 ];
var tmp = null;


tmp = document.createElement( "input" );
tmp.setAttribute( "type", "hidden" );
tmp.setAttribute( "value", "Testing a new input" );
tmp.setAttribute( "name", "hdnTest" );


frm.appendChild( tmp );

//Now it should work:
alert( frm.hdnTest.value );
}


With Mozilla it work perfect!

Regards,
LottaLava:D

brothercake
01-09-2004, 07:33 PM
Hmm .. might be IE being funny with setAttribute .. I can't remember the details of its problem, but try this

tmp.setAttribute( "value", "" );
tmp.value = "Testing a new input";

And if it's not that, try the same modification to each of the other setAttribute calls

LottaLava
01-09-2004, 07:38 PM
The problem isnīt that, what happens is about we cannot see hdnTest.

cheesebag
01-09-2004, 07:48 PM
http://www.codingforums.com/showthread.php?threadid=25460&highlight=form

liorean
01-09-2004, 07:52 PM
Ie has the problem that it's DOM implementation is built on top of it's document handling and rendering engines instead of into them. This leads (at least in some cases) to not including dynamically created form fields in the forms elements collection, and it doesn't submit them either. It's a problem that has existed in some form in all browsers, and is in iew not corrected.

LottaLava
01-09-2004, 07:56 PM
Thank you folks, i must say something about M$ IE, it sucks a lot!

Regards,
LottaLava

liorean
01-09-2004, 08:03 PM
It doesn't suck much, it's just old and underdeveloped/stagnated. Look at where Netscape/Mozilla, Opera and Konqueror stood when ie6w was created - it was the best at DOM and close to ie5m at css. Then moz wiped it off the floor with it's DOM support while op did the same with it's CSS support.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum