Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    text in button change on click - multiple times

    Hi there! I need help!

    Basically, I need to create a sentence and on one of the words the person accessing the site can click the word and it will change to another word and then again to a third word and so on for 5 words then it will, on click, return to the 1st word again. like a circle of various words.

    I've managed to get it to work with 2 words back and forth - but I need it to have multiple states. I need the JS and how to impliment it in the HTML. JS isnt my strong point just yet

    Please help me! Thanks so so much!

    follow me on twitter - @robyn_90

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,918
    Thanks
    56
    Thanked 545 Times in 542 Posts
    like so?
    Code:
    <html>
    <head>
    </head>
    <body>
    Here is a <a href="javascript:void(0)" onclick="changeWd(this)"> nice</a> little sentence.
    <script>
    words=["nasty","funny","sad","short"]
    var count=0;
    function changeWd(word){
    word.innerHTML=words[count++%words.length]
    }
    
    </script>
    </body>
    </html>
    but where is the button?

  • Users who have thanked xelawho for this post:

    gypsi (01-25-2012)

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    xelawho - THANK YOU!!! I like totally love you right now!


  •  

    Posting Permissions

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