Link to home
Start Free TrialLog in
Avatar of jeremyll
jeremyll

asked on

ASP classic: best way to do drop down list using <form>

ASP classic: What is the best way to do drop down list using <form>

I would like to store this info into a session variable or cookie. This info is input entered by the user who fills out a form.

Is below any help?

<html><body><form>

    <h2>HelloWorld<h2>

   <h3>What's your favorite colour?</h3>
   <select name='colour'>
      <option> red</option>
      <option> white</option>
      <option> blue</option>
    </select>
    </br>
    <input type=submit name="Submit" value="Submit"></input>
    <p>
        Hi, you selected <%=Request("colour") %>
    </p>
  </form>
</body></html>
Avatar of jeremyll
jeremyll

ASKER

image may help
image.jpg
try this.. this will add to session also...
<html><body><form>

    <h2>HelloWorld<h2>

   <h3>What's your favorite colour?</h3>
   <select name='colour'>
      <option> red</option>
      <option> white</option>
      <option> blue</option>
    </select>
    </br>
    <input type=submit name="Submit" value="Submit"></input>
    <p>
        <%=Session("color") = Request("colour") %>
        Hi, you selected <%=Session("colour") %>
    </p>
  </form>
</body></html>

Open in new window

You need to add an action to your form that guides the execution to a page where you store the value.

So:

<form method="POST" action="mySecondPage.asp">
...
...
</form>

And in your mySecondPage.asp you will do:

<%
Response.Cookies("myCookieColor") = Request.Form("colour").Value
%>
ASKER CERTIFIED SOLUTION
Avatar of Bob Butcher
Bob Butcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To use cookies, you would do something like this -
<%
Response.Cookies("colour") = Request("colour")
%>

I beleive that this statement must be before your HTML tag though :)
Do you think I need to make use of a sessionID for this exercise?