I am retrieving some values from a Database and I am displaying them in a form for editing. When editing is done, the values will be sent back to the DB.
I want to show a div if a radio with value "Yes" is checked and if a radio with value "No" is checked i want to show another div.
The checked value is coming from a database so it's not always on the same radio.
<input type="radio" name="longer" id="Yes" value="Yes" <?=($info['longer']=='Yes')?'checked':''?>>Yes
<input type="radio" name="longer" id="No" value="No" <?=($info['longer']=='No')?'checked':''?>>No
<div id="first">
Show if value is yes
</div>
<div id="second">
Show if value is no
</div>
This is the jquery code I had so far but it's not working:
$(document).ready(function() {
if ($('#No').prop('checked')) {
$('#first').hide();
$('#second').show();
} else if ($('#Yes').prop('checked') {
$('#second').hide();
$('#first').show();
}
});