Question

Asked on 2011-05-10 at 06:47:27ID: 27360751

JavaScript show/hide - need help adding to function

by: traport500

Rating8.5Very Good

Hi,

The following code is a show/hide based on the options in a dropdown. I need to add to this.

I need to add if parseInt (num) == 4 then show div #4

but I can't seem to get it working. Any help would be greatly appreciated!

<script language="javascript">
$(document).ready(function(){
      showHide($('select[name=newUserRoleID]').val());
});
function showHide(num)
{
	var showDiv = "#"+parseInt(num);
	$("div").hide();
	if(parseInt (num) == 2 || parseInt(num)==3 ||parseInt(num)==5)
	{
		$("#3").show(); 	}
	
	else
	{
		$(showDiv).show();
	}	
}

</script>
                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:

Select allOpen in new window

Related Solutions

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution

View This Solution - Start Your 30 Day Free Trial
Zone
general
Tags
JavaScript
Participating Experts
4
Solution Grade
A

Replies

 by: sammySeltzer

Posted on 2011-05-10 at 06:53:22ID: 36812571

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: cmalakar

Posted on 2011-05-10 at 06:54:26ID: 36812572

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: cmalakar

Posted on 2011-05-10 at 06:56:24ID: 36812573

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: MacAnthony

Posted on 2011-05-10 at 07:05:24ID: 36812574

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: ansudhindra

Posted on 2011-05-10 at 07:05:39ID: 36812575

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: MacAnthony

Posted on 2011-05-10 at 07:10:22ID: 36812576

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: ansudhindra

Posted on 2011-05-10 at 07:15:41ID: 36812577

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:06:26ID: 36812578

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: cmalakar

Posted on 2011-05-10 at 08:09:05ID: 36812579

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:16:45ID: 36812580

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:18:17ID: 36812581

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: cmalakar

Posted on 2011-05-10 at 08:20:00ID: 36812582

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: cmalakar

Posted on 2011-05-10 at 08:20:40ID: 36812583

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:24:59ID: 36812584

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:29:04ID: 36812585

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:32:16ID: 36812586

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: traport

Posted on 2011-05-10 at 08:33:01ID: 36812587

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Log In

Forgot your password?Sign up

Top Experts

  1. mplungjan

    1,840

    0 points yesterday

    Profile

BrowseAre you an Expert?