FoxWeb scripts run on the server, while JavaScript code runs on the browser. To set a JavaScript variable from FoxWeb code, you will need to create your JavaScript code dynamically at run time. The following example populates the MyFoxWebVar variable with the submitted value of the FirstName field and then populates the MyJavaScriptVar variable with the same value:
<%
MyFoxWebVar = Request.Form("FirstName")
%>
<html>
<head>
<script type="text/javascript">
var MyJavaScriptVar = '<%=MyFoxWebVar%>';
</script>
</head>
... more HTML |
Assuming that the FirstName field was populated with "Francisco", the output that is sent to the browser is:
<html>
<head>
<script type="text/javascript">
var MyJavaScriptVar = 'Francisco';
</script>
</head>
... more HTML |