Click to See Complete Forum and Search --> : ASP variable in Javascript function


Gopinath
06-22-2003, 12:42 AM
hi friends,
i declared one variable asp script. i want it to handle in javascript.
<%
bln_ret=comp_name(connection, xmlstr, session, err_str, xmlretstr)
if bln_ret then
var_1=xmlretstr
else
Response.write "Error"
end if
%>
i want to handle var_1 variable in javascript function
help pls

vickers_bits
06-22-2003, 01:07 AM
var myJSVar=<%=myASPVar%>

Bullschmidt
06-22-2003, 02:16 AM
And here's a little more info about mixing server-side ASP (which gets processed first) with client-side JavaScript.

It's easy to use the value of a VBScript variable in JavaScript:
document.writeln('<%= MyVBScriptVariable %>');

Or here is an example which puts the value of a VBScript variable into a JavaScript alert box:
Response.Write "<script language='JavaScript'>alert('The value is " & MyVBScriptVariable & "');</script>"

But to send the value of a JavaScript variable to VBScript, well that's another story. You could have the JavaScript fill in a hidden form field and then post the form. That way VBScript can pick up the value of the hidden form field with Request.Form("MyFieldName")