|
Subject:
|
html control with same id and name ???
|
|
Posted By:
|
muklee
|
Post Date:
|
10/21/2004 11:11:23 PM
|
If i have a form with multiple <input> tags, which all using the same id and name, what will happen if I call :
alert(document.form.inputName.value);
Is it possible to loop through all these <input> using javascript? And how to do that?
Thanks in advanced.
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
10/22/2004 12:49:58 AM
|
I think you will get an error but it's possible it will give you the value of one of the inputs, which one who knows? It's illegal to have two elements with the same id, names are allowed to be duplicated for radio buttons although browsers don't complain they just behave unpredictably. In IE if you use document.getElementsByName(<elementName>) then you get a collection of similarly named elements, with getElementById you get the first object with that id. If you have multiple ID's and names I'm not sure what will happen, worse still it might be random.
I suggest you change the design.
--
Joe
|