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

passing a variable from a form to another page

Status
Not open for further replies.

mal54

Programmer
Mar 11, 2002
13
AU
I have created a form drop down list driven by a data base I need to know how to pass a hidden variable from this form to another page. I need some code please.
 
Try this...

I assume within your <form> tag you have entered method=&quot;post&quot; action=&quot;my_next_page.asp&quot; which will do the form redirect when you press the Submit button.

Your drop down list will need to have a name, for example:
<select name=&quot;my_drop_down&quot;>

... and drop down list items will need to have a value - this can be what is passed into the next page. For example, <option value=&quot;Hello&quot;>Hello</option>

In &quot;my_next_page.asp&quot; within some <% %> tags enter:

' --- Carry forward the the value of my_drop_down ---
my_passed_value = request.form(&quot;my_drop_down&quot;)

To check the value has carried over send it to the screen:

Response.Write my_passed_value

Hope this helps,
Craig
 
If you, in addition to the information in the drop-down list, want to send some other kind of info, you can use this within the form tags:
Code:
<input TYPE=&quot;HIDDEN&quot; value=&quot;<%=yourVariable%>&quot; name=&quot;aVariable&quot;>

To retrieve it on the next page, its standard operating procedure:
Code:
theVariable = Request.Form(&quot;aVariable&quot;)

Hope this helps,
Palooka
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top