4 replies [Last post]
rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 9 years 4 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

Is there any simple way of loading a set of hyperlinks, Once a user has pressed on one.

So if a user pressed on a hyperlink called Cars

Ford
Vaxhall

Other Hyperlinks would appear below this

The Cyber World

Tags:
Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 1 day ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

DIVS Visible

rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 9 years 4 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

DIVS Visible

Hiya Tony

I may need some help on this..... I have done what I thought would work, but doesnt seem to work

Here is the code

<HTML>


<HEAD>
<SCRIPT LANGUAGE="JavaScript">

function showorhide(id)
{ 
   if(document.getElementById(id))

{    //check the element exists and can be accessed 
       var ele = document.getElementById(id);    //get hold of the element 
       if(ele.style.display=="yellow"){   //see if display property is set to none, switch classe 
           ele.style.display="red";        
       }else{ 
           ele.style.display="none";      
       } 
   } 
} 

</SCRIPT>
<STYLE TYPE="text/css">

.yellow	{background-color: yellow ; }
.red	{background-color: red ; }

</STYLE>
</HEAD>
<BODY>

<P onClick="showorhide()">Hello this is A paragraph that might change if you click on it</P>




</BODY>
</HTML>

The Cyber World

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 1 day ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

DIVS Visible

Hi rmcivo1,
Yes you have a few thing wrong.
Your original post seems to aim for a different result then you are now trying for.
display is a css property that can be set to block, inline and none or some others that you can look up.

try this

 
function showorhide(id) 
{ 
   if(document.getElementById(id)) 
 
{    //check the element exists and can be accessed 
       var ele = document.getElementById(id);    //get hold of the element 
       if(ele.style.display=="none"){   //see if display property is set to none, show the box 
           ele.style.display="block";        
       }else{ 
           ele.style.display="none";      
       } 
   } 
} 

 
<a href="#" onclick="showorhide('theboxid')" >show or hide</a> 
<div id="theboxid" > this is the box that will show or hide as it has the id I am passing to the function</div>

If you want to change the class you use.
document.getElementById('theboxid").className="newclass";
[/code]

rmcivo1
Offline
Enthusiast
Shropshire | Shrewsbury
Last seen: 9 years 4 weeks ago
Shropshire | Shrewsbury
Joined: 2003-12-05
Posts: 115
Points: 0

DIVS Visible

Thank you tony, you have put me on the right tracks again. I dont know what I was thinking about.

Thank you ever so Much
Rees

The Cyber World