Click to See Complete Forum and Search --> : pass ASP variable to JScript
xghoulx
03-07-2008, 10:46 AM
serverside:
this is the only method i found for splitting a QueryString in ASP... but now i need to use that variable in my javascript function... thanks
<%
Dim imdbLink
ID = Request.QueryString("u")
ID_split = Split(ID, "/title/")
imdbLink = ID_split(1)
%>
<script language="javascript" runat="server">
Response.Write(imdbLink);
</script>
TheBearMay
03-07-2008, 11:03 AM
You'll need to "write" the value into the javascript:
<%
Dim imdbLink
ID = Request.QueryString("u")
ID_split = Split(ID, "/title/")
imdbLink = ID_split(1)
%>
<script type="text/javascript">
var imdbLink = "<%= imdbLink %>";
...
</script>
xghoulx
03-07-2008, 11:07 AM
You'll need to "write" the value into the javascript:
<%
Dim imdbLink
ID = Request.QueryString("u")
ID_split = Split(ID, "/title/")
imdbLink = ID_split(1)
%>
<script type="text/javascript">
var imdbLink = "<%= imdbLink %>";
...
</script>
that's if I want it sent back to the Client... this is for ServerSide JavaScript... so that won't work :( already tried it.
xghoulx
03-07-2008, 02:29 PM
figured it out... lots of different things come into play here
first off i didnt have a language tag uptop
<%@LANGUAGE="JavaScript"%>
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
Dim imdbLink
If Request.QueryString("u") = "" Then
imdbLink = "error"
Else
ID = Request.QueryString("u")
ID_split = Split(ID, "/title/")
imdbLink = ID_split(1)
End if
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" RUNAT="Server">
Response.Write(imdbLink);
</SCRIPT>
i read that only one script language can be used at a time.. so you must set the top to the main one you want to use... then have a your vbscript above and the rest has to be javascript. weird to understand at first but if you wanted to call javascript vars from VB you would have to reverse whats up there.