views:

29

answers:

0

Hey there,

I've programmed a tingy snippet that should be able to tick a checkbox if someone types into a specific textfield.

The problem is that I have a bunch of checkboxes having the same name but not the same id's. They are all different.

<input type="checkbox" value="11" id="checkbox_09" name="CHAP2_PART4_1[]">
<input type="checkbox" value="11" id="checkbox_010" name="CHAP2_PART4_1[]">

... ...

The textfield has the id="text_0". My jQuery/javascript code looks like this:

$("body[page=3]").ready(function()
{
    if($("input#text_0").val() != "")
    {
        $("input#checkbox_010").attr("checked", true);
    }
    else
    {
        $("input#checkbox_010").attr("checked", false);
    }
}

The code works for a small ammount of checkboxes but for an ammount of ten, there are getting a lot of them checked. I have 11 checkboxes from 0 to 10 and 3,4 - 6,7 and 10 are checked but only 10 should be checked because I'm using the seperator input#checkbox_010 only.