Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery radiobutton show hide div question

Posted on 2009-07-13
2
Medium Priority
?
2,774 Views
Last Modified: 2012-05-07
Hi there, i have two radio buttons that should show/hide two divs, I am using jquery here is my code, as far as i can tell both divs are hidden on load but the checkbox does not show them. using the latest jquery.
<script type="text/javascript">
    $(document).ready(function(){
	$("#hourlydiv, #fixedfee").hide();
    
	if($("input[name='type']:checked").val() =="hourly") {
            $("#hourlydiv").show("fast");
            $("#fixedfeediv").hide("fast");
	} else if ($("input[name='type']:checked").val() =="fixed") {
            $("#hourlydiv").hide("fast");
            $("#fixedfeediv").Show("fast");
	}
});
 
     </script>

Open in new window

0
Comment
Question by:cookiejest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Assisted Solution

by:strickdd
strickdd earned 800 total points
ID: 24842150
you need to create an onclick function that will show/hide the div's, the ready function will only be called when the page is done loading.
0
 
LVL 4

Accepted Solution

by:
SadafRasheed earned 1200 total points
ID: 24842842
try this
<script type="text/javascript">
    $(document).ready(function(){
        $("#hourlydiv, #fixedfee").hide();
    
		$("input[name='type']").click(function (){
		
			if($("input[name='type']:checked").val() == "hourly" ) {
				$("#hourlydiv").show("fast");
				$("#fixedfeediv").hide("fast");
			} else if ($("input[name='type']:checked").val() =="fixed") {
				$("#hourlydiv").hide("fast");
				$("#fixedfeediv").Show("fast");
			}
		});
		
        
});
 
</script>

Open in new window

0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

688 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