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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable from page to page

Status
Not open for further replies.

dtran

Programmer
Jun 25, 2001
29
US
Please help!!
I am trying to pass a variable from one page to another.
I have a variable that I received from server side vbscript that I used in client side javascript. I am trying to do a : location.href = &quot;page.asp?tempVar=myVariable&quot; in javasacript where myVariable is the variable that I am using to pass to the next page. I can't use &quot;<form action=blah blah> and then reference it with request.queryString(&quot;myVariable&quot;) because I am doing something else with that.
I hope I explained that right.

Thanks in advance.
 
Hi dtran,

If you use the GET method, the values are posted as querystrings. As a result you can still use request.queryString(&quot;myVariable&quot;).

If you use the POST method, you should use:
request.form(&quot;myVariable&quot;)

Hope it helps you further?

Gtz,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
I guess I didn't explained that right.
I have a javascript function that I want to pass a variable to page.asp. I can't use &quot;Post&quot; or &quot;Get&quot; with request.form or request.querystring because the original page is using that to pass another variable to anotherpage.asp.
 
Hi,

Indeed, you got me confused :)

Can you post an example of the code you are using?

Tnx,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
<html>
<head>
<form action=&quot;page1.asp&quot; method=&quot;Post&quot;>
<%
//data connection blah blah
myVar = rs(&quot;Name&quot;)
%>
<body>

</form>
</body>
</html>
<script language=&quot;javascript&quot;>
function passVar
{
//do some stuff
//this where I need the code

location.href=&quot;page2.asp?myName=<%=rs(&quot;Name&quot;)%>

//I've tried using Session(&quot;myName&quot;) = Session
and <%=rs(&quot;Name&quot;)%> but none seem to work.
}

</script>
 
Hi dtran,

This should do it:

Code:
<%
data connection blah blah
myVar = rs(&quot;Name&quot;)
%>

<html>
<head>
<title>Pass variable</title>
<script language=&quot;javascript&quot;>
function passVar()
{
	document.location.href='page2.asp?myName=<%=myVar%>'
}
</script>
</head>

<body>
<form action=&quot;page1.asp&quot; method=&quot;Post&quot; name=&quot;myForm&quot;>
	<input type=&quot;text&quot; name=&quot;myVar&quot; value=&quot;<%=myVar%>&quot;>
</form>
<A HREF=&quot;javascript:passVar()&quot;>passVar</a>
</body>
</html>

Sure hope it does :p

Gtz,

Kristof -------------------
Check out my new site:

Any suggestions are more than welcome.
There's a LOT of work to do, so judge fairly. :)
 
Thanks alot all.
I was a great help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top