Solved

jquery to display different content based on radio selection

Posted on 2011-03-21
3
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

734 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