Forums » Advanced Editor Forum » Read Thread

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

Using JS to change variables

4 months ago

So I found out you can include javascript to change PAGETEXT, for example like

$PAGETEXT:= "(script)

bla bla bla some cool js code....

And it works for adding text or buttons or whatever. But is there a way to use js to change regular variables? I tried

%VAL:="(js code that returns number, for example (script)document.write(7);(/script))"

When I try to do this it stores 0 in %VAL, I guess because everything inside the quotation marks is translated to a string.

The same goes for changing DEST:

$DEST:= "@P"+"7"

works well, but

 $DEST:= "@P"+"(script)document.write(7);(/script)"


Does anyone know how to change other variables than PAGETEXT with js? Or alternatively how to use js variables to change pages in the storygame- because the main reason I need to store the js variables in the storygame %VARIABLES is to use them to change to other pages. Plus I'm not sure if the js variables get saved when passing between pages so that's another thing.

That's about it, any helpful and nonhelpful comments are appreciated.

Using JS to change variables

4 months ago
I'm pretty sure that's not possible, because the script on the site is evaluated on the server; while javascript is evaluated on the client.

Using JS to change variables

4 months ago

Ah, I guess that makes sense. Thanks for answering!