Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 04, 2012 09:16 AM by coolpal9
Member
157 Points
527 Posts
Apr 26, 2012 12:54 PM|LINK
Hi,
In my web form, I am using javascript function, which checks the previously selected value using if..else. If the value belongs to a certain set of functions, then it should show "label1" else it should show "label2".
But somehow, this is not happening right.
Pl check my code:
function ShowHideType(ListObject) { var LinkObj = $(ListObject); if (LinkObj.val() == "AI" || "CN" || "CD" || "DM" || "LD" || "ND" || "PD" || "SB") { $(".NC").show(); $(".CM").hide(); } else { $(".NC").hide(); $(".CM").show(); } }
Star
8079 Points
1491 Posts
Apr 26, 2012 01:03 PM|LINK
throw an alert inside your function. also are you sure that you have your class name correct?
coolpal9 function ShowHideType(ListObject) { var LinkObj = $(ListObject);
function ShowHideType(ListObject) { alert($(ListObject).val()); <--- see what this is }
also when you do this....
if (LinkObj.val()
it should be
if (LinkObj.value == ......
or
if ($(LinkObj).val() == ......
b/c .val() is a jquery function, not a javascript function
Contributor
2816 Points
450 Posts
Apr 26, 2012 01:05 PM|LINK
var val = LinkObj.val(); if (val == "AI" || val == "CN" || val == "CD" || val == "DM" || val == "LD" || val == "ND" || val == "PD" || val == "SB") {
Apr 26, 2012 01:07 PM|LINK
oh i think you're right somnathmali.... can't believe i missed that =x
Apr 26, 2012 01:13 PM|LINK
@somnathmali
Thanks a lot! Its working right.
May 04, 2012 09:16 AM|LINK
somnathmali var val = LinkObj.val(); if (val == "AI" || val == "CN" || val == "CD" || val == "DM" || val == "LD" || val == "ND" || val == "PD" || val == "SB") {
Hi again,
This was the case for dropdownlist, what if all these values were fed into a checkboxlist?
Then in that case, how can one code for show/hide? I am facing a problem now with checkboxlist...
Hope you can help me out...
coolpal9
Member
157 Points
527 Posts
Problem in javascript function...
Apr 26, 2012 12:54 PM|LINK
Hi,
In my web form, I am using javascript function, which checks the previously selected value using if..else. If the value belongs to a certain set of functions, then it should show "label1" else it should show "label2".
But somehow, this is not happening right.
Pl check my code:
function ShowHideType(ListObject) { var LinkObj = $(ListObject); if (LinkObj.val() == "AI" || "CN" || "CD" || "DM" || "LD" || "ND" || "PD" || "SB") { $(".NC").show(); $(".CM").hide(); } else { $(".NC").hide(); $(".CM").show(); } }robwscott
Star
8079 Points
1491 Posts
Re: Problem in javascript function...
Apr 26, 2012 01:03 PM|LINK
throw an alert inside your function. also are you sure that you have your class name correct?
function ShowHideType(ListObject) { alert($(ListObject).val()); <--- see what this is }also when you do this....
it should be
or
b/c .val() is a jquery function, not a javascript function
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
somnathmali
Contributor
2816 Points
450 Posts
Re: Problem in javascript function...
Apr 26, 2012 01:05 PM|LINK
var val = LinkObj.val(); if (val == "AI" || val == "CN" || val == "CD" || val == "DM" || val == "LD" || val == "ND" || val == "PD" || val == "SB") {.NET Developer , Pune INDIA.
Please Mark As Answer If my reply helped you.
robwscott
Star
8079 Points
1491 Posts
Re: Problem in javascript function...
Apr 26, 2012 01:07 PM|LINK
oh i think you're right somnathmali.... can't believe i missed that =x
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
coolpal9
Member
157 Points
527 Posts
Re: Problem in javascript function...
Apr 26, 2012 01:13 PM|LINK
@somnathmali
Thanks a lot! Its working right.
coolpal9
Member
157 Points
527 Posts
Re: Problem in javascript function...
May 04, 2012 09:16 AM|LINK
Hi again,
This was the case for dropdownlist, what if all these values were fed into a checkboxlist?
Then in that case, how can one code for show/hide? I am facing a problem now with checkboxlist...
Hope you can help me out...