Solved

Display textarea when radio button is selected

Posted on 2012-03-12
3
542 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

23 Experts available now in Live!

Get 1:1 Help Now