View Full Version : problems with forms and dynamic input elements
01-09-2004, 07: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!
01-09-2004, 08: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
01-09-2004, 08:38 PM
The problem isnīt that, what happens is about we cannot see hdnTest.
01-09-2004, 08:48 PM
01-09-2004, 08: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.
01-09-2004, 08:56 PM
Thank you folks, i must say something about M$ IE, it sucks a lot!
01-09-2004, 09: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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.