Solved

Display textarea when radio button is selected

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 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