al3bed
08-28-2009, 02:45 PM
hello
im newbie here :) im not good in javascript but i need this code
i want a function check if 3 checkboxes are checked
and if they checked then it's will disable other checkboxes!
as i say im not good in javascript.. this is my try:
function check_disable(box) {
var index = 0;
for(var i=0;i<box.form.elements.length;i++)
{
if(box.form.elements[i].checked == true)
{index = index + 1;}
else if(box.form.elements[i].checked == false)
{index = index - 1;}
}
if(index >= 3)
{
for(i=0;i<box.form.elements.length;i++)
{
box.form.elements[i].disabled = !box.checked;
}
}
}
-->
</script>
i put onclick="check_disable(this);" in each checkbox
this not work :o
any help please
thanks
im newbie here :) im not good in javascript but i need this code
i want a function check if 3 checkboxes are checked
and if they checked then it's will disable other checkboxes!
as i say im not good in javascript.. this is my try:
function check_disable(box) {
var index = 0;
for(var i=0;i<box.form.elements.length;i++)
{
if(box.form.elements[i].checked == true)
{index = index + 1;}
else if(box.form.elements[i].checked == false)
{index = index - 1;}
}
if(index >= 3)
{
for(i=0;i<box.form.elements.length;i++)
{
box.form.elements[i].disabled = !box.checked;
}
}
}
-->
</script>
i put onclick="check_disable(this);" in each checkbox
this not work :o
any help please
thanks