head
HTML-Kodu:
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Alan Gruskoff | http://www.performantsystems.com/ */
function anyCheck(form) {
var total = 0;
var max = form.ckbox.length;
for (var idx = 0; idx < max; idx++) {
if (eval("document.playlist.ckbox[" + idx + "].checked") == true) {
total += 1;
}
}
alert("You selected " + total + " boxes.");
} body
HTML-Kodu:
<form method="post" name=playlist>
1<input type=checkbox name=ckbox> <br>2<input type=checkbox name=ckbox> <br>3<input type=checkbox name=ckbox> <br>4<input type=checkbox name=ckbox> <br>5<input type=checkbox name=ckbox> <br>6<input type=checkbox name=ckbox> <br>7<input type=checkbox name=ckbox> <br>8<input type=checkbox name=ckbox> <br>9<input type=checkbox name=ckbox> <p><input type=button value="Count Checkboxes" onClick="anyCheck(this.form)"> </form>