Topic: input type radio does not change value when clicked
Everton Gabriel
pro
asked 6 years ago
Michal Szymanski
staff
answered 6 years ago
<form>
<div id='type'>
<p>
<input type='radio' id='radio_1' name='radio1' value='1' />
<label for="radio_1">Red</label>
</p>
<p>
<input type='radio' id='radio_2' name='radio1' value='2' />
<label for="radio_2">Red</label>
</p>
<p>
<input type='radio' id='radio_3' name='radio1' value='3' />
<label for="radio_3">Red</label>
</p>
</div>
</form>
$("input").on('change', function () {
var s = $(this).val();
alert(s);
});
When you click any of the radio button it will alert the value of it. That proves radio works as expected and you can save a value in your form to submit it.
Everton Gabriel
pro
answered 6 years ago
<p>
<input name="group1" type="radio" id="test1" value="1" />
<label for="test1">Red</label>
</p>
When I click the Red radio in the screen I need the input to be checked:
<p>
<input name="group1" type="radio" id="test1" value="1" checked />
<label for="test1">Red</label>
</p>
This already works for checkboxes, why not for radio buttons?
Tks
Michal Szymanski
staff
answered 6 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
- User: Pro
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No