HOW TO EXCHANGE VARIABLES BETWEEN BASIC AND JAVASCRIPT??
Posted:
Wed Jul 08, 2020 9:21 am
by EdithBratt
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
Re: HOW TO EXCHANGE VARIABLES BETWEEN BASIC AND JAVASCRIPT??
Posted:
Fri Jul 10, 2020 8:41 am
by Luc Volders
Took me some time to figure it out.
Here you go:
Code: Select all'=========================================================
'working code
'puts a button on screen. Prompts for a variable
'sends variable to basic
'=========================================================
wprint |<body>|
wprint |<button id="btnPrompt" onclick = "sendcode();">Click to give a code</button>|
wprint |<div id="result"></div>|
wprint |<script>|
wprint |function sendcode()|
wprint |{|
wprint |var code = prompt("fill in your value ", "value");|
wprint |var quote = "The value you gave was: " + code;|
wprint |document.getElementById("result").innerHTML = quote;|
wprint | window.event.returnValue = false;|
wprint | var xmlHttp = new XMLHttpRequest();|
wprint | xmlHttp.open("GET", "msg?sendcode=" + code, false);|
wprint | xmlHttp.send(null);|
wprint | return xmlHttp.responseText;|
wprint |}|
wprint |</script>|
wprint |</body>|
wprint |</html>|
msgbranch [message]
wait
[message]
foundcode = msgget("sendcode")
print "you typed " & foundcode
wait
Luc