Wednesday, August 18, 2010

How do I pass a variable in ASP code and have that variable show up in the URL?

I am programming an .ASP file. I want the person to be able to fill out there first and last name and on the next page they are sent to I want their first and last name to show up in the URL. Can you explain how to do this or recommend a web site?How do I pass a variable in ASP code and have that variable show up in the URL?
Hi,





You don't need ASP to do this - passing variables in the URL is a standard HTML form function (although you will need ASP, or another server side language, to retrieve those variables).





Use the GET method for the 'method' of your form. The data will be appended to the URL you specify in the 'action' of the form.





EG:





%26lt;form action=';processform.asp'; method=';get';%26gt;


%26lt;input type=';text'; name=';firstname'; value=';John';%26gt;


%26lt;input type=';text'; name=';lastname'; value=';Smith';%26gt;


%26lt;input type=';submit'; value=';Submit';%26gt;


%26lt;/form%26gt;





When submitted will land the user at processform.asp?firstname=john%26amp;lastname=鈥?br>




For your information, the POST method is generally considered a cleaner way to handle forms. You can read more about forms, the GET and POST methods at the w3 schools website - http://www.w3.org/TR/html4/interact/form鈥?/a>How do I pass a variable in ASP code and have that variable show up in the URL?
why not simplify your problems by sending it to a database and then recover it back for the database on the next screen

No comments:

Post a Comment