Internet Advertising - Insurance Articles Directory - Kamala Harris - Debt Consolidation - Free online video sharing India

PDA

View Full Version : checkboxes checking respective texboxes empty or not


goutam.dutta123
Oct 4th 2007, 11:28 pm
Please help.....
My problem is that checkboxes are not checking respective textboxes empty or not.Here is my code:

function check(xform)
{
i = 0, inputs = document.xform.getElementsByTagName('input');
while (i<9)
{
if (inputs[i].type == 'checkbox' && inputs[i].checked)
{
if(document.getElementById('quan[]').value=="")

{
alert('specify the quantity');
return false;
}
}
i++;
}
}
My checkboxes are moving in a loop:
<input type="checkbox" name="chkID[]" id="chkID[]" value="<?=$rowSubjectsx['ID']?>">
Textboxes are also moving in a loop:
<input type="text" name="quantity[]" id="quan[]" size="3"/>
Please help............

james_r
Oct 5th 2007, 7:32 pm
you don't have an onclick event in your checkbox code:

<input type="checkbox" name="chkID[]" id="chkID[]" value="<?=$rowSubjectsx['ID']?>" onclick="check(document.forms[0]);">

Also, I wouldn't use [] in the Id and Name tags of the checkboxes and text boxes, but that's just me. Never tried it, but it seems like you're making it more complicated than it needs to be.

goutam.dutta123
Oct 5th 2007, 11:58 pm
you don't have an onclick event in your checkbox code:

<input type="checkbox" name="chkID[]" id="chkID[]" value="<?=$rowSubjectsx['ID']?>" onclick="check(document.forms[0]);">

Also, I wouldn't use [] in the Id and Name tags of the checkboxes and text boxes, but that's just me. Never tried it, but it seems like you're making it more complicated than it needs to be.

It works.Thank you very much .