Help please!!

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 19th, 2006, 15:14
New Member
Join Date: Aug 2006
Location: Portugal
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote

  #2 (permalink)  
Old Sep 19th, 2006, 16:11
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
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.
Reply With Quote
  #3 (permalink)  
Old Sep 19th, 2006, 16:21
New Member
Join Date: Aug 2006
Location: Portugal
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #4 (permalink)  
Old Sep 19th, 2006, 21:14
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Help please!!

Code: Select all
 function hideShow()
{
var obj, args=hideShow.arguments;
 
switch(args[0])
{
case "1":
var arg1="experience" + args[0];
arg1=document.getElementById(arg1);
Where do you think the first item highlighted above is coming from?

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?
Reply With Quote
Reply

Tags
help

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43