Page 1 of 1
How to pass a string variable from SB to inline JS
Posted: Mon Mar 24, 2014 1:32 pm
by the.weavster
Is it possible to pass a string variable from SB to inline JS?
If so would somebody be kind enough to show me how it's done?
Re: How to pass a string variable from SB to inline JS
Posted: Mon Mar 24, 2014 3:14 pm
by Peter
Code: Select all
Define myString.s = "World!"
!alert("Hello " + v_myString);
Greetings ... Peter
Re: How to pass a string variable from SB to inline JS
Posted: Mon Mar 24, 2014 4:13 pm
by the.weavster
Thanks, Peter.
Any idea how to make this work?
Code: Select all
Procedure.s SayHello(myString.s)
!return "Hello " + v_myString;
EndProcedure
Debug SayHello("Peter")
Re: How to pass a string variable from SB to inline JS
Posted: Mon Mar 24, 2014 4:24 pm
by Peter
this doesn't work at the moment due to this bug:
http://forums.spiderbasic.com/viewtopic.php?f=11&t=38
Greetings ... Peter
Re: How to pass a string variable from SB to inline JS
Posted: Mon Mar 24, 2014 8:24 pm
by the.weavster
Thanks again, Peter.
Why is it necessary to prefix the variable name with 'v_' in the JavaScript code?
Re: How to pass a string variable from SB to inline JS
Posted: Tue Mar 25, 2014 6:27 am
by Foz
because it's internal "compiled" code that you shouldn't be looking at?
I'm guessing to ensure that there isn't a conflict of variable names between all the javascript libraries and your code, so all variables are prefixed with "v_".