Answer the question
In order to leave comments, you need to log in
How to hang up handlers on input radio change?
I have a form that contains two radio inputs and an inactive text input
<form name="form1" id="form1">
...
<label><input type="radio" name="radio1" value="0" checked/>Нет</label>
<label><input type="radio" name="radio1" value="1"/>Да</label>
<input type="text" value="100" name="input1" disabled/>
...
</form>
Answer the question
In order to leave comments, you need to log in
form1.onchange = function(e){
if(e.target.name == "radio1"){
this.elements.input1.disabled = !+e.target.value;
}
}
$("#form1").on("change", "input[name=radio1]", function(){
var $this = $(this);
$this.next("input[name=input1]").prop("disabled", !+$this.val());
//this.form.elements.input1.disabled = !+this.value;
});
Should I use the click or change event?
And is it possible to hang a handler on the radio array without using a loop?Only if you use jquery (and then, there will still be a cycle inside).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question