|
Q5821 How can I pass server-side variables to client-side script?
irt.org | Knowledge Base | ASP | Q5821 [ previous next ]
Q5821 How can I pass server-side variables to client-side script?
ASP writes text (aka client-side code) so HTML, Javascript whatever type is
available can be written. All you do is simply place variables in the correct
spots and check the source code produced to make sure the client-side
code is being written correctly.
<%
' ASP AND CLIENT SCRIPT:
Dim xValue, yValue, increment
xValue = 123
yValue = 47
increment = 5
' WRITES THE CLIENT-SIDE SCRIPT:
response.write "<!-- CLIENT SEES: -->" & vbCrLF
response.write "<script language='javascript'>" & vbCrLF
response.write "<!--" & vbCrLF
response.write "// CALL THE moveIt() FUNCTION (NOT SHOWN) " &
vbCrLF
response.write "// WITH THE ASP-PASSED PARAMETERS" & vbCrLF
response.write "" & vbCrLF
response.write "moveIt(" & xValue & ", " & yValue &
", " & increment & ")" & vbCrLF
response.write "" & vbCrLF
response.write "//-->" & vbCrLF
response.write "</script>" & vbCrLF
%>
<!-- CLIENT SEES: -->
<script language='javascript'>
<!--
// CALL THE moveIt() FUNCTION (NOT SHOWN)
// WITH THE ASP-PASSED PARAMETERS
moveIt(123, 47, 5)
//-->
</script>
|
Feedback on 'Q5821 How can I pass server-side variables to client-side script?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.