Display textarea when radio button is selected

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.
LVL 8
ZadoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
YZlatConnect With a Mentor Commented:
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
 
ansudhindraConnect With a Mentor Commented:
0
 
ZadoAuthor Commented:
Thanks, it works.
0
All Courses

From novice to tech pro — start learning today.