SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast kong's Avatar
    Join Date
    Jan 2008
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face toggleDisplay - Issue

    Hello i have some toggleButton issues.

    If i click the button i want to display a table

    I have tried this example code but it dont seem to work.
    Also another question: what happens if i have another onclick event. Is it possible to have 2. And if so how should i write it. Sorry i am still new with javascript

    <table id="myTable">
    </table>

    <input id="toggleButton" type="button" onclick="hideTable(true);" value="Toggle Table" /

    function toggleDisplay(var hide) {
    if (hide) {
    document.getElementById('myTable').style.display = "none";
    document.getElementById('toggleButton').onclick = hideTable(false);
    } else {
    document.getElementById('myTable').style.display = "table";
    document.getElementById('toggleButton').onclick = hideTable(true);
    }
    }

    kind regards

  2. #2
    SitePoint Enthusiast kong's Avatar
    Join Date
    Jan 2008
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello i have fixed my problem.
    Instead of using a button i decided to use a check box and that seem to work.

    I am still wondering if it is possible to use 2 on click events.

    Thanks anyway

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,710
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by kong View Post
    I am still wondering if it is possible to use 2 on click events.
    You can have two click events on the same element. In situations like that it's better to use advanced event registration to do so.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •