Results 1 to 6 of 6

Thread: How many tricks to ...

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face How many tricks to ...

    Can anyone post some tricks for making something like a toggle button?? Like a link which does two actions(onclick). If you click it once it expands a div and if you click again it contracts. I have been trying to do that for ages but what I found was one of the scripts in w3schools which is sth like:

    Code:
    var cc=0;
    if(cc=0){
    cc=1;
    //do something
    } else {
    cc=0;
    //do something
    }
    If anyone has any other tricks then please post them in this thread.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If the actions set a variable, all you have to do is check that one.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Twey, jscheuer1 I am looking forward to some more tricks.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I think NTL (big British broadband provider, similar to AOL in America) have decided it's Experience Life as a Snail week -- my connection currently measures at 715 bytes per second. Anyway...

    You can also toggle the whole event:
    Code:
    <button id="btn">A button</button>
    <script type="text/javascript">
    function toggleOn() {
      // do something
      this.onclick = toggleOff;
    }
    
    function toggleOff() {
      // do something else
      this.onclick = toggleOn;
    }
    
    document.getElementById("btn").onclick = toggleOn;
    </script>
    All depends on what you want to do and what else you've got to measure by.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ah!! Twey I have never seen any of that kind. LOVE IT!!!!

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
  •