Hide fieldset when radio button is clicked

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Hide fieldset when radio button is clicked

Post by thiscatis »

Hi,


As you can see on this page: http://www.12solve.be/survey/survey.php?id=1
I'm using this javascript with jQuery to toggle the questions

Code: Select all

<script type="text/javascript"> 
$(document).ready(function() {
	var showText="Show";
	var hideText="Hide";
 
	$(".toggle").prev().append(' (<a href="#" class="toggleLink">'+hideText+'</a>)');
  
	$('a.toggleLink').click(function() {
 		if ($(this).html()==showText) {
			$(this).html(hideText);
		}
		else {
			$(this).html(showText);
		}
 		$(this).parent().next('.toggle').toggle('slow');
		
		return false;
 
	});
});
 
//-->
</script>
I wonder if it's possible to also call the hide event when someone clicks on a radio button (they answer a question and the fieldset hides like it would do with the Show/Hide link)

Thanks in advance!
hyperblue
Forum Newbie
Posts: 1
Joined: Mon Jun 28, 2010 11:26 pm

Re: Hide fieldset when radio button is clicked

Post by hyperblue »

Code: Select all

<script type="text/javascript"> 
$(document).ready(function() {
	var showText="Show";
	var hideText="Hide";
 
	$(".toggle").prev().append(' (<a href="#" class="toggleLink">'+hideText+'</a>)');
  
	$('a.toggleLink').click(function() {
 		if ($(this).html()==showText) {
			$(this).html(hideText);
		}
		else {
			$(this).html(showText);
		}
 		$(this).parent().next('.toggle').toggle('slow');
		
		return false;
 
	});
	
	$("input[type=radio]").click(function(){
		$(this).parent('.toggle').toggle('slow');
	})
});
 
//-->
</script> 
Right?
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Re: Hide fieldset when radio button is clicked

Post by thiscatis »

Yeah, I tried that but it does not let me access the showText en hideText field to change it from Show to Hide.
Post Reply