Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.