Hellow, I want to make function with js, with who I can count checboxes witch is checked, page countaines only checboxes and text. Every text entry is with it's ID where is one checkbox belove it. I have about 20 checkboxes and I want to do thing like this - check 2 or 3 whatever how much checkboxes and send by ID to print.php?=$id page. And the text I get from datebase what's why I need ID. Got smth like this by it's wrong: function checkbox(form) { var url = "print.php"; var all = 0; var max = form.checkbox.length; for (var idx = 0; idx < max; idx++) { if (eval("document.form[" + idx + "].checked") == true) { visi += 1; } } alert("checked" + all "); }
On sight, I see two mistakes: function checkbox(form) { var url = "print.php"; var all = 0; var max = form.checkbox.length; for (var idx = 0; idx < max; idx++) { if (document.form[idx].checked == true) //why eval? { visi += 1; } } alert("checked" + all); //removed the " at the end } Code (markup):
function checkbox(form) { var url = "print.php"; var all = 0; var max = form.checkbox.length; for (var idx = 0; idx < max; idx++) { if (document.form[idx].checked == true) //why eval? { visi += 1; } } alert("checked" + all); //removed the " at the end } Okey, and how can I send to print.php?=$id ?