Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign javascript variable = vbscript variable

Status
Not open for further replies.

jeffcullina

Programmer
May 13, 2002
80
US
I pass an argument from one page to another in the address line. On the second page, I can reference that argument with vbscript by using

ID = Response("ID")

I would like to make use of that ID value in a javascript function. How do I set a javascript variable equal to a vbscript variable (something equivalent to IDjava = ID)? Alternatively, can I get the argument from the address line in javascript (is there a javascript equivalent to Response("ID"))?

Thanks,
Jeff
 


I have already done this with ASP:

Code:
IDjava = &quot;<% =IDasp %>&quot;

vlad
 
I get bad results when I try to pass a value between the two. What I would do is...:

<script language=javascript>
function useVal(){
//get the val from the form
jsID = document.myForm.tranferVal.value
}
</script>
<script language=vbs>
sub moveVal()
ID = Response(&quot;ID&quot;)
document.myForm.tranferVal.value = ID
end sub
</script>
<body onLoad=&quot;moveVal()&quot;>
<form name=myForm>
<input type=hidden name=&quot;transferVal&quot;>
</form>


Javascript has a way to parse the querystring. The whole value of the querystring is in the location.search object:

wholeString = location.search.substring(1) //to peel off the ? mark... -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Something like this:

<%
dim ID
ID = Response(&quot;ID&quot;)
%>

<script language=&quot;javascript&quot;>
<!--
var target = <%=ID%>;

</script>

Hope this helps,
Erik <-- My sport: Boomerang throwing !!
!! Many Happy Returns !! -->
 
Vlad & boomerang's response works if you are using asp pages... I got the impression, that you are just working in html.... -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top