Solved

Display textarea when radio button is selected

Posted on 2012-03-12
3
546 Views
Last Modified: 2012-03-12
Hi Experts,

I need a simple script doing this:
I have 2 radio buttons, by default first button is selected and first textarea is shown, but when I select second button, I want to display another textarea (replacing previous one).
In other words: Two radio buttons and two textareas, first radio button is linked to first textarea, second button to second textarea. I want to switch between those textareas (show/hide) when selecting radio buttons. I hope it's clear :-) Thanks.
0
Comment
Question by:Zado
3 Comments
 
LVL 13

Assisted Solution

by:ansudhindra
ansudhindra earned 250 total points
ID: 37710080
0
 
LVL 35

Accepted Solution

by:
YZlat earned 250 total points
ID: 37710098
try something like that:

$(document).ready(function () {
		        toggleRadioButtons();

		    });



		    function toggleRadioButtons() {
			$("#rb").click(function() {     
				var value = $(this).val();
				if (value=="r1") {

		                	$('#area2').hide();
					$('#area1').show();
				}else{
					$('#area1').hide();
					$('#area2').show();
				}
			}); 
			
 

		    }

Open in new window

0
 
LVL 8

Author Closing Comment

by:Zado
ID: 37710469
Thanks, it works.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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