Link to home
Start Free TrialLog in
Avatar of befidled
befidled

asked on

jquery to display different content based on radio selection

I have the following radio buttons:

 

I have a hidden div with a class="options2" that has display:none set. If a user selects option 2, I would like to change it to be changed to display:block.  

What is the best way to accomplish this?
<div class="input-fields-rfq">
	<label>Option 1</label><br />
	<div><input class="end_user" type="radio" name="end_user" value="1" style="width:30px;"></div>
</div>

<div class="input-fields-rfq">
	<label>Option 2</label><br />
	<div><input class="end_user" type="radio" name="end_user" value="2" style="width:30px;"></div>
</div>

<div class="input-fields-rfq">
	<label>Option 3</label><br />
	<div><input class="end_user" type="radio" name="end_user" value="3" style="width:30px;"></div>
</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or
//this is going to hide the previous option and show the new one
 $("input[name='end_user']").click(function(){
   $(".options1").hide();
   $(".options2").hide();
   $(".options3").hide();
   var value =  $(this).val();
   $(".options" + value ).show();
});

Avatar of befidled
befidled

ASKER

Perfect. Thanks for the quick response!

brian