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>
ASPWeb DevelopmentHTML

Avatar of undefined
Last Comment
jeremyll

8/22/2022 - Mon
ASKER
jeremyll

image may help
image.jpg
Praveen Venu

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

Bardobrave

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
%>
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Bob Butcher

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Bob Butcher

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 :)
ASKER
jeremyll

Do you think I need to make use of a sessionID for this exercise?