Results 1 to 4 of 4

Thread: change on click help

  1. #1
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default change on click help

    Hey guys, I am a the most basic beginner you have known and I need your help.

    I am working on launching a small firm and I need your help in coding something
    It is probably very simple...

    In some of the pages on the site, I have a list of links (check the home page for example)
    I am having challenges with the change on click command/ Now if you click on the link 'Mind your own business' for example, it will display certain text.
    how can i make the text disappear on the second click?
    this is the current code:
    <a href="#" onclick="changeText(6);">Mind your own business</a><div id="text_description_6">&nbsp;</div><A>

    thanks in advance

  2. #2
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Maybe something like:

    Trigger
    Code:
    onClick="changeText('textuwantchangedhere');"
    Head code
    Code:
    changeText(text) {
    var value=document.getElementById("div").innerHTML;
    
    if (value=="") {
    document.getElementById("div").innerHTML='' + text;
    }
    
    else {
    document.getElementById("div").innerHTML='';
    }
    }
    The area with text
    Code:
    <div id="div"></div>
    Note that this is untested, just a guess. It works by checking to see if the DIV is empty, if it is then it inserts the text, if not then it wipes it empty. On first click add text, on second get rid of it. If the code doesn't work (likely) at least you have something to go on. If I have time and you still need it I'll try and make it work late,r assuming it doesn't now.

    Good luck,
    Tim
    Wow, I was just reading past posts and man I was a butthole sometimes to people. So if you ever got the end of it, then sorry...

  3. #3
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a lot man, i will be testing it tonight to see.... i will let you know if it works

  4. #4
    Join Date
    May 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    what do you think of the site?

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
  •