I have a JS that shows a test field if "1" is selected from a radio button. And hides if "0" is selected. It's working while the text field is hidden from the beginning but not if I want the text field to be visible as default if the value is "1" from the database.
JS
$(document).ready(function() {
$("#send_to_yes").hide();
$("input:radio[name=\'article\']").change(function() {
if(this.value == \'1\' && this.checked){
$("#send_to_yes").show();
}
else {
$("#send_to_yes").hide();
}
});
});
HTML
Yes <input type="radio" name="article" value="1">
No <input type="radio" name="article" value="0">
<div id="send_to_yes">
<b>Number</b> <br><input type="text" name="number"><br><br>
</div>
CSS
#send_to_yes {
display: none;
}
The "1" and "0" comes from a database. With this code I need to press "Yes" and then the text field comes up. Even if "Yes" is checked I need to press it. I want it to be visible if "1" (Yes) is checked as default.