admin管理员组文章数量:1333710
in my jsp form i have one checkbox Array in my form(jsp and struts).i want to know the length of checkbox Array in java script. ex: <input:checkbox property="chkbox[]"/>
. in javascript i am calling document.form[0].chkbox[].value.length
but it showing javaScript error null or undefined .
in my jsp form i have one checkbox Array in my form(jsp and struts).i want to know the length of checkbox Array in java script. ex: <input:checkbox property="chkbox[]"/>
. in javascript i am calling document.form[0].chkbox[].value.length
but it showing javaScript error null or undefined .
2 Answers
Reset to default 3 var checkbox = document.getElementsByName('a_checkbox')
var ln = checkbox.length
line 1 get all the active checked boxes line 2 in the length of that array
if this the html
<form name='form1' >
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
<input type=checkbox name='cbox' />
</form>
javascript for that length would be
alert(document.form1.cbox.length);
or you can also use.
document.getElementsByName('cbox').length
本文标签: javascriptHow can get CheckBox Array length in java scriptStack Overflow
版权声明:本文标题:javascript - How can get CheckBox Array length in java script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742346776a2457680.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论