checkboxes checking respective texboxes empty or not

Discussion in 'JavaScript' started by goutam.dutta123, Oct 4, 2007.

  1. #1
    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.type == 'checkbox' && inputs.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............
     
    goutam.dutta123, Oct 4, 2007 IP
  2. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    james_r, Oct 5, 2007 IP
  3. goutam.dutta123

    goutam.dutta123 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It works.Thank you very much .
     
    goutam.dutta123, Oct 5, 2007 IP