This is a discussion on "Help please!!" within the JavaScript Forum section. This forum, and the thread "Help please!! are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Help please!!
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Help please!!
Hello guys!
This is my problem: I have a html table with two div# layers in it div#experience1 and div#test1 i'm using a jsscript to hide show each div the code is: function hideShow() { var obj,args=hideShow.arguments; switch(args[0]) { case "1": var arg1="experience" + args[0]; arg1=document.getElementById(arg1); var arg2="experience" + 2; arg2=document.getElementById(arg2); arg1.style.visibility="visible"; arg1.style.display="block"; arg2.style.visibility="hidden"; arg2.style.display="none"; break; case "2": var arg1="experience" + args[0]; arg1=document.getElementById(arg1); var arg2="experience" + 1; arg2=document.getElementById(arg2); //arg1.style.visibility="visible"; //arg1.style.display="block"; arg2.style.visibility="hidden"; arg2.style.display="none"; break; } } function hideShow2() { var obj,args=hideShow.arguments; switch(args[0]) { case "1": var arg1="test" + args[0]; arg1=document.getElementById(arg1); var arg2="test" + 2; arg2=document.getElementById(arg2); arg1.style.visibility="visible"; arg1.style.display="block"; arg2.style.visibility="hidden"; arg2.style.display="none"; break; case "2": var arg1="test" + args[0]; arg1=document.getElementById(arg1); var arg2="test" + 1; arg2=document.getElementById(arg2); //arg1.style.visibility="visible"; //arg1.style.display="block"; arg2.style.visibility="hidden"; arg2.style.display="none"; break; } } </script> the first set of radio buttons call function hideShow and work fine, here is the code: <input name="job" type="radio" onClick="javascript:hideShow('1');" value="0"> <input name="job" type="radio" onClick="javascript:hideShow('2');" value="1" checked> on the other hand the second set of radio buttons that call function hideShow2 don't work at all. what am i doing wrong? Please help |
|
|
|
|||
|
Re: Help please!!
You are not calling hideshow2(). You are calling hideshow('2'). You could fine this code down to one function and pass it the variable of the div you want visible. It looks from your calling code that this was you intention but not from the way you have written the functions. Also, visibility and display serve two different purposes. You do not need; visibility: hidden; and display: none; The visibility: hidden; attribute hides the element but the browser leaves empty space for it on the page. The display: none; attribute hides the element and no space is left. Everything flows inot place as if the element didn't exist. |
|
|||
|
Re: Help please!!
I'm sorry i forgot to post the code for the second set of buttons, here it is:
<input name="experience" type="radio" onClick="javascript:hideShow2('1');" value="0"> <input name="experience" type="radio" onClick="javascript:hideShow2('2');" value="1" checked> Thanx |
|
|||
|
Re: Help please!!
The second highlighted item will never work because none of your elements have 'id's. I'm beginning to think you don't understand this code at all. Where did you get it from? |
![]() |
| Tags |
| help |
| Thread Tools | |
|
|