FoxWeb code in an FWX script is executed on the server before the resulting output is sent to the browser. JavaScript code on the other hand, is executed on the browser, after output is returned by FoxWeb.
You can set JavaScript variables to be equal to VFP variables as follows:
<%
M.VFP_Var = "Some Value"
%>
<script language="javascript">
JS_Var = '<%=M.VFP_Var%>';
alert(JSVar);
</script> |
The resulting code that would be sent to the browser in this case would be:
<script language="javascript">
JS_Var = 'Some Value';
alert(JSVar);
</script> |
If on the other hand you want to send JavaScript variables back to FoxWeb, you will need to somehow make a trip to the Web server. In the following example, the value entered by the user on the browser is sent to FoxWeb as part of the query string:
<html><head>
<script language="javascript">
var theResponse = window.prompt("Please enter your name","");
window.location.href = 'http://apps.foxweb.com/show_cgi.fwx?response=' + theResponse;
</script>
</head>
<body>
No need for content
</body>
</html> |
FoxWeb Support Team support@foxweb.com email |
Sent by Michael Pena on 01/09/2003 07:09:09 PM:
How do we extract a value from a JavaScript variable to Foxweb variable
on the same page without using POST or GET?
My example would be if possible :
<script language="JavaScript">
mTEXT1 = "hello"
<%
mFWTEXT1 = mTEXT1
Response.write(mFWTEXT1)
%>
</script>
However as we know an error would occur.
Can you give me a way to do this?
Thanks again.