Jump to content

*SOLVED* JS not working


coldkill

Recommended Posts

I'm making a website where the navigation is supposed to be hidden until the user clicks on the roll out button and it displays the links. Only problem is the JavaScript doesn't change the style tag for the table with the links in which has the style attribute.

Here is the javascript [code]function hide_toggle( id )
{
    document.getElementById(id).style.display=document.getElementById(id).style.display=="none" ? "" : "none"
}
[/code]

here is the html (dynamically generated)
[code]<!-- Menu Item 1-6 -->
    <tr><td>
     <div class="mhead">
     <input name="" type="button" title="Asssault AirLift: AirLift" onclick="javascript:hide_toggle( 'linkcat1' )" value="AirLift" />
    
     </div>

     <div class="menu">
      <table  id="linkcat1" cellpadding="0" cellspacing="0" border="0" style="display:none">
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=home" title="Assault AirLift: Go Home!!">Home</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&amp;c=gen" title="Assault AirLift: Contact Us! Yes US!">Contact Us</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&amp;c=app" title="Assault AirLift: It's unpaid btw ¬¬">Job Application</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&amp;c=bug" title="Assault AirLift: NOOOOOO A BUG!!">Bug Report</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=memlist" title="Assault AirLift: Our members r0xers your s0xers!">Member's Listing</a></td></tr>

        
      </table>
     </div>
    </td></tr>[/code]
The above is one menu item and isn't the entire menu bar.

Thanks in advance,
Cold
Link to comment
https://forums.phpfreaks.com/topic/7972-solved-js-not-working/
Share on other sites

Hi there,,

The code there seems OK to me,... it shows the navigation links & changes the table style display correctly once we have clicked on the button,, (tested with both IE & FF)
[code]
<html>
<body>
<script type="text/javascript">

function hide_toggle( id )
{
    document.getElementById(id).style.display=document.getElementById(id).style.display=="none" ? "block" : "none"
}
</script>
<!-- Menu Item 1-6 -->
    <tr><td>
     <div class="mhead">
     <input name="" type="button" title="Asssault AirLift: AirLift" onclick="javascript:hide_toggle( 'linkcat1' )" value="AirLift" />
    
     </div>

     <div class="menu">
      <table  id="linkcat1" cellpadding="0" cellspacing="0" border="0" style="display:none">
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=home" title="Assault AirLift: Go Home!!">Home</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&c=gen" title="Assault AirLift: Contact Us! Yes US!">Contact Us</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&c=app" title="Assault AirLift: It's unpaid btw ¬¬">Job Application</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=contact&c=bug" title="Assault AirLift: NOOOOOO A BUG!!">Bug Report</a></td></tr>
        <tr><td><a href="http://www.assault-airlift.com/index.php?module=memlist" title="Assault AirLift: Our members r0xers your s0xers!">Member's Listing</a></td></tr>

      </table>
     </div>
    </td></tr>
</body>
</html>
[/code]
Is it what you were looking for,...?

hoping it helps,

l8tr,,
Link to comment
https://forums.phpfreaks.com/topic/7972-solved-js-not-working/#findComment-30247
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.