name相同获取值

时间:2021-12-17 04:49:19
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="" >
<p>
<input type="text" name="plan_bm_num[]" id="plan_bm_num[]" value="">,
<input type="text" name="plan_bm_num[]" id="plan_bm_num[]" value="">,
<input type="text" name="plan_bm_num[]" id="plan_bm_num[]" value="">,
<input type="text" name="plan_bm_num[]" id="plan_bm_num[]" value="">
</p>
<p>
<label for="plan_total_renshu"></label>
<input type="text" name="plan_total_renshu" id="plan_total_renshu">
</p>
<p>
<input type="button" name="button" id="button" value="按钮" onClick="check();">
</p>
</form>
</body>
</html>
<script language="javascript">
function check(){
var bm_num=;
var names =document.getElementsByName("plan_bm_num[]");
for(i=;i<names.length;i++){
value=names[i].value;
console.log(value);
}
}
</script>