...

View Full Version : text in button change on click - multiple times



gypsi
01-25-2012, 03:20 PM
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 :( :confused:

Please help me! Thanks so so much!

follow me on twitter - @robyn_90

xelawho
01-25-2012, 03:47 PM
like so?


<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?

gypsi
01-25-2012, 03:53 PM
xelawho - THANK YOU!!! I like totally love you right now!:p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum