-->
Page 1 of 1

How to exchange variables between Basic and Javascript

PostPosted: Sat Dec 23, 2017 8:46 pm
by Luc Volders
I am trying to do the following

In basic I have a variable let's say x

How do I access that variable with Javascript
let javascript perform some actions on it
let Basic get the result back from javascript

Any ideas ???
Any example please

Luc

Re: How to exchange variables between Basic and Javascript

PostPosted: Mon Dec 25, 2017 11:57 am
by Mmiscool
Make a text box in the page. Then use the cssid command to hide that text box. You can then use it and when you change the value it should trigger the on change event for that text box.

Also if you are running a program you can take a peak at the browser debugger by pressing f12. You can see the bit of JavaScript used to pass variable back and forth and trigger those functions manually.

Re: How to exchange variables between Basic and Javascript

PostPosted: Wed Dec 27, 2017 2:47 pm
by Luc Volders
Thanks Mike.
Been trying but get no results.
I was trying to do something like this:

Code: Select allx = 10
button "change", [change]
button "end", [progend]
textbox x

wprint |<!DOCTYPE html>|
wprint |<html>|
wprint |<body>|
wprint |<script>|

wprint |var a = 10 * x|

wprint |</script>|

wprint |</body>|
wprint |</html>|
wait

[change]
x = a
print a
print x
wait

[progend]
end
wait



so first I declare x in basic
next in javascript I say a = 10 * x
and then in basic I print a and x

did not work. Any example please ???
An example for sending a variable to javascript and an example for retrieving a variable from javascript would be great.

Luc

Re: How to exchange variables between Basic and Javascript

PostPosted: Sun Mar 04, 2018 11:18 am
by Luc Volders
Don't worry
Found it

Luc