I doubt you will want to give all of your INPUTs the same name, so you can also do this: <i> </i><body> <form> <div> <span name="myName"><input type="hidden" name="we1" value="el1"></span> <span name="myName"><input type="hidden" name="we2" value="el2"></span> </div> </form> <script type="text/javascript"> var els=document.getElementsByName("myName") for(var i=0,l=els.length; i<l; i++){ alert(els[i].firstChild.value) } </script> </body>
Because IE sucks, you need to add this code in: <i> </i>document.getElementsByName=function(a){ var allels=document.getElementsByTagName("*"); var findings=[]; for(var i=0;i<allels.length;i++){ if(allels[i].getAttribute("name")==a)findings[findings.length]=allels[i] } return findings }
@KorMay 24.2006 — #... which brings you back to the same loop whithin the elements with the same [I]something[/I], using an if() conditioner (an attribute's value), which is absolutely the same thingh.