Debt Consolidation - Kamala Harris - Myspace Layouts - Debt Consolidation - IKA Lab Equipment

PDA

View Full Version : js - checkbox count - print


wtfn00b
Jun 28th 2008, 3:06 am
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 ");
}

Randombase
Jun 28th 2008, 7:13 am
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
}

wtfn00b
Jun 29th 2008, 1:10 am
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 ?

wtfn00b
Jun 30th 2008, 10:09 pm
Thank you.