Jump to content

show/hide


chriscloyd

Recommended Posts

this is my problem im trying to make the link have a background color if thats the boxid that is showing this is my code can you help me please

 

<script>
function showstuff(boxid){
   document.getElementById(boxid).style.visibility="visible";
}
function showlink(boxid){
   document.getElementById(boxid).style.visibility="visible";
}
function hidestuff(boxid){
document.getElementById(boxid).style.color="#000000";
document.getElementById(boxid).style.background-color="#999999";
}
function hidelink(boxid){
   document.getElementById(boxid).style.visibility="hidden";
}
</script>
<link href="boe.css" rel="stylesheet" type="text/css" />
<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr>
    <td><a onclick="showstuff('cs16'); hidestuff('CSS'); hidestuff('zp');">CS 1.6</a> <a onclick="showstuff('CSS'); hidestuff('cs16'); hidestuff('zp'); ">CSS</a> <a onclick="showstuff('zp'); hidestuff('cs16'); hidestuff('CSS');">ZP</a> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td><div id="cs16">
Server 1
Server 2
Server 3
Server 4
Server 5
</div><div id="CSS" style="visibility:hidden">
Server 1
Server 2
Server 3
Server 4
Server 5
</div><div id="zp" style="visibility:hidden">
Server 1
Server 2
Server 3
Server 4
Server 5
</div></td>
    <td> </td>
    <td> </td>
  </tr>
</table>
<p> </p>

Link to comment
https://forums.phpfreaks.com/topic/141729-showhide/
Share on other sites

What exactly is wrong?

 

DOM elements in JavaScript do not contain dashes, the next word is capitalized. So background-color is actually backgroundColor.

 

Also just to add, you could do all this from one single function. You're going the extra long way around...

 

Adam

Link to comment
https://forums.phpfreaks.com/topic/141729-showhide/#findComment-742025
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.