mercredi 22 juillet 2015

Disable input if checkbox checked

i want to disable inputs when a checbox is checked.

part of html:

 <div class="span1 ">
  <div class="control-group" id="niedziela">
    <label class="control-label" for="">Niedziela</label>
    <div class="controls">
      <input type="text" value="<?= $metavalue->nightlife_open_7_start ?>" name="meta[nightlife_open_7_start]" id="nightlife_open_7_start" class="m-wrap span12 timepicker-24" placeholder="">
      <input type="text" value="<?= $metavalue->nightlife_open_7_end ?>" name="meta[nightlife_open_7_end]" id="nightlife_open_7_end" class="m-wrap span12 timepicker-24" placeholder="">
      <input id="klient_open_4_end" type="checkbox" <?=_ set_checked($metavalue->nightlife_open_7_end,'do ostatniego klienta') ?> value="do ostatniego klienta" name="meta[nightlife_open_7_end]" class="m-wrap span12 timepicker" placeholder=""> Do ost. klienta
      <input id="zamkniete_open_4_end" type="checkbox" <?=_ set_checked($metavalue->nightlife_open_7_start,'zamkniete') ?> value="zamkniete" name="meta[nightlife_open_7_start]" class="m-wrap span12 timepicker" placeholder=""> Zamknięte
    </div>
  </div>
</div>

what i want is that if checkbox with id klient_open_4_end is checked it should disable input with id="nightlife_open_7_end"

if checkbox with id="zamkniete_open_4_end" is checked should disable both inputs text areas

i tried with :

<script type="text/javascript">
  $(document).ready(function($) {
    $('#klient_open_4_end').change(function() {
      $(this).find("#nightlife_open_7_start").attr("disabled", true);
    });
  });
</script>




Aucun commentaire:

Enregistrer un commentaire