js获取相同name文本框的value
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" language="javascript"> function aa() { var r = document.getElementsByName("city"); for (var i = 0; i < r.length; i++) { alert(r[i].value); } } </script> </head> <body> <form name="form1" method="post" action="" runat="server"> <input type="text" name="city" value="苏州" /><br /> <input type="text" name="city" value="无锡" /><br /> <input type="text" name="city" value="南通" /><br /> <input type="button" onclick="aa()" value="button"> </form> </body> </html> 来源: https://www.cnblogs.com