WatchNon-threaded

Forums » Advanced Editor Forum » Read Thread

Talk about it. Ask for help on it. Compliment it.

[Scrpting?] Link change color & text when clicked

6 years ago

I hope this is possible with scripting. But having read the tutorials on scripting, I feel overwhelmed by it, it's kind of difficult for me to understand it

So, in the Quiz game i am making, if the player clicks a wrong answer, the fail count is increased by 1, and that answer becomes unclicable (because I have set the link limit to 1 and made it visible when unactive). However, it would be really useful if I could also change the color of the unactive link to red, and maybe change it's text (so it would add '- WRONG' to it

[Scrpting?] Link change color & text when clicked

6 years ago

The way I'd do it, which is probably a little tedious, is by having a variable for each incorrect answer separately, which is set to 1 if the link is clicked. Then, if that particular variable is 1, changing the specific $LINKTEXT# (numbered based on the order of the links on a specific page, so the first link is $LINKTEXT1, the second is $LINKTEXT2, etc.) for that page. Something like:

IF %WRONG1 = 1 THEN BEGIN
$LINKTEXT1 := "<span style='color:red;'>" + $LINKTEXT1
$LINKTEXT1 := $LINKTEXT1 + " - WRONG</span>"
END

Which would, if the variable %WRONG1 is equal to 1, alter the text of the first link on the page, beginning a red-colored span HTML element in front, then appending " - WRONG" to the end and closing the span element. You'll need to have a block of code like this for every possible wrong link.

[Scrpting?] Link change color & text when clicked

6 years ago

Well, i have tried doing it for one link, but it doesn't seem to be working.

Am i not understanding something about script usage?

I see that scripts can be attached to a link, or to the page. So where should i add this? To every link?

[Scrpting?] Link change color & text when clicked

6 years ago

This particular one would go in a page script. Also, make sure you're using the proper link number and variable.

[Scrpting?] Link change color & text when clicked

6 years ago

I'm not very good at this stuff. 

[Scrpting?] Link change color & text when clicked

6 years ago

You're on Safari, aren't you? No one besides you can see whatever image you're posting. You need to upload it to an image hosting site first.

[Scrpting?] Link change color & text when clicked

6 years ago

Oh......sorry.

[Scrpting?] Link change color & text when clicked

6 years ago

Yep, it works perfectly now, thanks for the info :)

[Scrpting?] Link change color & text when clicked

6 years ago

Nice! Glad to help.