If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Okay...this code should work in all except older MSIE. (Older MSIE doesn't allow you to add a type to an <input> created via document.createElement in the manner done here.) It works in MSIE 9 and I believe it works in MSIE 8, but not sure.

SOlder MSIE doesn't allow you to add a type to an <input> created via document.createElement in the manner done here.

Are you sure you're not getting the type and name attributes mixed up?

IE 8 and earlier will allow you to assign a type to an input field that was created using createElement but only allow you to set the value once. If you want to change the type in those browsers you have to swap out the input field and replace it with a new field that has the new type assigned to it - for example http://javascriptexample.net/domform08.php

IE 8 and earlier do not allow you to add a name attribute to an input field that has been created using createElement. You have to use a special proprietary version of createElement to add the name during the create - for example http://javascriptexample.net/domform06.php

Users who have thanked felgall for this post:

Name. I meant name. Been so long since I worried about it I forgot which it was. SORRY!

Thanks, Felgall!

And that also answers your question, Xelawho, if somewhat indirectly. button vs. input wouldn't matter: still couldn't give a name dynamically. Actually, the button doesn't need a name, so the problem applies to all the other elements.

Last edited by Old Pedant; 02-28-2013 at 10:42 PM.

An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.