I'm trying to get an input box to be visible / not visible depending on whether a radio button is selected on yes or no.
I have assigned an ID to each div where the text input box is.
<tr>
<td>Acknowledged within 30 secs</td>
<td>
<div class="radio"><input type="radio" value="1" name="greet"> Yes</div>
<div class="radio"><input type="radio" value="0" name="greet"> No</div>
</td>
</tr>
<tr>
<td></td>
<td>
<div id="greet-info" class="hidden">
<input type="text" class="textbox" placeholder="Tell us more" id="greet_more" name="greet_more">
</div>
</td>
</tr>
$("input[name='greet']").change(
function(){
if($('input[name=greet]:checked').val()=="0"){
$('#greet-info').removeClass("hidden");
}else{
$('#greet-info').addClass("hidden");
}
}
);
$("input[name='menu']").change(
function(){
if($('input[name=menu]:checked').val()=="0"){
$('#menu-info').removeClass("hidden");
}else{
$('#menu-info').addClass("hidden");
}
}
);
$("input[name='drinks_menu']").change(
function(){
if($('input[name=drinks_menu]:checked').val()=="0"){
$('#drinks_menu-info').removeClass("hidden");
}else{
$('#drinks_menu-info').addClass("hidden");
}
}
);
Since I have a lot of questions, and they are spread across 5 pages. I will need a lot of input boxes, and therefore i'll have to re-write the function out each time. I was wondering how I could do it so I only have to write one function?
Thanks!
trs