user1148875 user1148875 - 1 year ago 76
Javascript Question

How can get length on checked checkbox array javascript

<form name='form1' >
<input type=checkbox name='cbox[]' />

var checkbox = document.getElementsByName('ckbox[]')
var ln = checkbox.length

How can I count only the checked checkboxes with javascript or jQuery?

Answer Source

Doing it with jQuery would shorten the code and make it more readable and maintable. Use attribute selector with :checked selector

Live Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download