Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   Связать <input>'ы (https://javascript.ru/forum/misc/7499-svyazat-input-%27y.html)

Rasie1 04.02.2010 15:04

Связать <input>'ы
 
Как сделать так, чтобы при нажатии на этот checkbox(можете менять параметры):
<input type="checkbox" value="OK" class="mchat" id="secuCodeMc3">
скрывалась эта кнопка:
<input type="submit" value="OK" class="mchat" id="mchatBtn" style="width:30px;">
заранее спасибо.

Nicko 04.02.2010 15:14

window.onload = function() {
  var box = document.getElementById('secuCodeMc3');
  box.onchange = function() {
    var button = document.getElementById('mchatBtn')
    if (this.checked) {
      button.style.display = 'none';
    } else {
      button.style.display = '';
    }
  }
}



// Или через jQuery
$(function() {
  $("#secuCodeMc3").change(function() {
    var button = $("#mchatBtn");
    if (this.checked) {
      button.hide();
    } else {
      button.show();
    }
  });
});

Rasie1 04.02.2010 19:08

спасибо, отлично работает, поставил плюс


Часовой пояс GMT +3, время: 01:52.