Solved

jquery to display different content based on radio selection

Posted on 2011-03-21
3
286 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:befidled
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 35180411
$("input[name='end_user']").click(function(){
   if ( $(this).val() == "1" )
   {
      $(".options1").show();
   }
   if ( $(this).val() == "2" )
   {
      $(".options2").show();
   }
   if ( $(this).val() == "3" )
   {
      $(".options3").show();
   }
});
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35180437
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();
});

0
 
LVL 1

Author Closing Comment

by:befidled
ID: 35180539
Perfect. Thanks for the quick response!

brian
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now