Jump to content


Photo

*SOLVED* JS not working


  • Please log in to reply
5 replies to this topic

#1 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 20 April 2006 - 05:22 PM

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
function hide_toggle( id )
{
    document.getElementById(id).style.display=document.getElementById(id).style.display=="none" ? "" : "none"
}

here is the html (dynamically generated)
<!-- 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>
The above is one menu item and isn't the entire menu bar.

Thanks in advance,
Cold


You can learn alot from reading the manual

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 April 2006 - 07:11 PM

change "" to "block" instead.

#3 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 21 April 2006 - 03:51 PM

Didn't work. Strange thing is the exact same JS function works on another site I have it on.


You can learn alot from reading the manual

#4 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 24 April 2006 - 05:24 PM

Any ideas? Still not working.
Thanks.


You can learn alot from reading the manual

#5 GBS

GBS
  • Members
  • PipPipPip
  • Advanced Member
  • 108 posts

Posted 24 April 2006 - 08:02 PM

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)
<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>
Is it what you were looking for,...?

hoping it helps,

l8tr,,
Sorry for my english,... I do my best, but sometimes,...
1st intention: understand the problem
2nd intention: try to solve it
3rd intention: try to understand how to solve it :)

#6 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 24 April 2006 - 10:03 PM

Thanks.
The reason it didn't work from the file was because i put the whole URL in instead of just the folder ie js/main.js

Thanks for help

::SOLVED::


You can learn alot from reading the manual




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users