faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 31 people (71%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Newbie Question -------> How to pass variables to a VBScript

Jun 19th, 2002 12:39
Mark Grimes, Luiz Paulo Rosa, Alex Rosales,


Suppose you have a file named test.asp
You can send in the URL:
   test.asp?var1=test&var2=test2
where var1 and var2 are your variables. 
Notice that you must use '?' after file name and '&' when you have more 
than one variable.
To retrieve data in test.asp script you use Request.QueryString("var1") 
and Request.QueryString("var2")
(Don't forget the 'http://' stuff)
Or you can use a form:
<FORM METHOD=POST ACTION="test.asp">
<INPUT TYPE="text" NAME="var1">
<INPUT TYPE="text" NAME="var2">
</FORM>
If you use METHOD=POST, you can retrieve data using Request.Form
("var1") and Request.Form("var2"). If you use METHOD=GET, use 
Request.QueryString("var1").
If you are not sure how the data is sent to ASP, simply use Request
("var1") and Request("var2"). Works in both ways (GET and POST).
>>------------
Also, you could use session variables.  For example:
page1.asp:
<%
session("var1") = "foo"
session("var2") = "bar"
%>
page2.asp:
<%
var1 = session("var1")
var2 = session("var2")
%>
This is particularly usefull if you want to use the variables on 
several different pages (instead of explicitly having to pass them each 
time).



© 1999-2004 Synop Pty Ltd