Page 1 of 1

Hide fieldset when radio button is clicked

Posted: Sun Sep 19, 2010 6:55 am
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!

Re: Hide fieldset when radio button is clicked

Posted: Sun Sep 19, 2010 10:36 pm
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?

Re: Hide fieldset when radio button is clicked

Posted: Fri Sep 24, 2010 5:38 am
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.