-
Posts
14 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Eep²
-
-
This is how I script in Second Life and it works fine, except for this change:
function changepic(img_name,img_src) {document[img_name].src=img_src;} function changepic1() { var o = 0; if (!o) { changepic('circles','circular_infinity1.png'); o++; } else if (o==1) { changepic('circles','circular_infinity_intersected1a.png'); o++; } else { changepic('circles','circular_infinity1a.png'); o = 0; } }
But it still doesn't work past the first if. The boolean operator (==) is used to make sure o does indeed equal a specific #. Regardless, just using "=" doesn't work either. A dynamic local variable can or can't be zero; hence why I test for it in the beginning to begin the if-elses.
Got any actual answers instead of questions?
-
I'm trying to make a script that will change an image several times after the image is clicked. So, if the image is clicked once, the image changes, if clicked again, the image changes again, etc. I'm trying to use a variable that increases in amount but it doesn't seem to be working for some reason. Any ideas? Thanks.
function changepic(img_name,img_src) {document[img_name].src=img_src;} function changepic1() { var o = 0; if (!o) { changepic('circles','circular_infinity1.png'); o++; } else if (o==1) { changepic('circles','circular_infinity_intersected1a.png'); o++; } else {changepic('circles','circular_infinity1a.png')} o = !o }
condtional if-else
in JavaScript
Posted
Thanks! Declaring the variable outside the function fixes it. "!o" works as expected too.