Hi,

One of my HTML forms uses pairs of "checkbox/text" inputs.
Each checkbox is printed on the left of the text input, but is written
before that field as it must be justified on the right (float:right).

<li>
<input name="footer_company" type="text" style="float:right;" />
<input name="footer_company_checkbox" type="checkbox"
checked="checked">Company name :</input>
</li>

I would like to disable each text input for which the corresponding
checkbox doesn't have the "checked" status.

I could retrieve the checkboxes that are preceded by a text field and
find which ones are in unselected mode.
But I was then unable find for each unchecked checkbox the preceding
text field so that I can disable it.

The ".disabled=true" also does not disable any text field.

$(':text~:checkbox').each(
  function(){
    if(!this.checked) {
      $(':text').css('background-color','yellow'); // This works but
selects all text inputs.
      $(':text').disabled=true; // This does not work.
    }
  }
);

Thanks for any help.

Julien

Reply via email to