Jump to content

pass a variable from JScript to ASP function


joecool2005
 Share

Recommended Posts

Is it possible to pass a variable in Javascript to a ASP function?I want to do something like this.----------------------------------------------------------------------------------<%sub check(temp) Response.Write(temp&"<br>")end sub%><script>var varJS=123document.write("<%call check(varJS)%>")</script>----------------------------------------------------------------------------------I don't know how to pass a varJS to ASP subThxJoe

Link to comment
Share on other sites

When I do this, ----------------------------------------------------------------------------------<%sub check(temp) dim varASP varASP="abc" Response.Write(temp=varASP)end sub%><script> var varJS="abc" document.write('<%call check("'+varJS+'")%>')</script>----------------------------------------------------------------------------------Why it returns false when I compare varJS and varASP?Both of them are they string?ThxJoe

Link to comment
Share on other sites

You could do this in an asp page or html or something else:

<html><head><script language="vbscript"><!--  sub check(temp)    document.write("vbscript: "&temp)  end sub--></script></head><body><script language="javascript"><!--  var javaVar = 10;  document.write("javascript: "+javaVar+"<br />");  check(javaVar);//--></script></body></html>

Link to comment
Share on other sites

Thank you for your help.I tried to run your code and I got false. When I used the "len" function to verify, I got different length. It's weird!<%sub check(temp)dim varASPvarASP="abc"Response.Write(len(temp)&" "&len(varASP))end sub%><script>var varJS="abc"document.write('<%call check("'&varJS&'")%>')</script>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...