i am new to asp and would much appreciate your help with my problem.
i am trying to retain the selected "state" input from my form's drop down menu after it is posted and then gets returned to the form page for incorrect or additional input on the form. Presently, the input the user selected disappears when redirected back to the form. So when the user selects a state from the drop down list, how can i have it reappear in the selected field after posting so the user does not have to input it over again.

here is a bit of my code i have tried but it does not work as of yet.

<select name="State">
<option value="">&lt;Select State&gt;</option>
<option value="AL"<% If State = "AL" Then Response.Write(" selected=""selected""") %>>Alabama</option>
<option value="AK"<% If State = "AK" Then Response.Write(" selected=""selected""") %>>Alaska</option>
<option value="AZ"<% If State = "AZ" Then Response.Write(" selected=""selected""") %>>Arizona</option>
<option value="AR"<% If State = "AR" Then Response.Write(" selected=""selected""") %>>Arkansas</option>
<option value="CA"<% If State = "CA" Then Response.Write(" selected=""selected""") %>>California</option>
<option value="CO"<% If State = "CO" Then Response.Write(" selected=""selected""") %>>Colorado</option>
<option value="CT"<% If State = "CT" Then Response.Write(" selected=""selected""") %>>Connecticut</option>
<option value="DC"<% If State = "DC" Then Response.Write(" selected=""selected""") %>>District of Columbia</option>
<option value="DE"<% If State = "DE" Then Response.Write(" selected=""selected""") %>>Delaware</option>
<option value="FL"<% If State = "FL" Then Response.Write(" selected=""selected""") %>>Florida</option>
<option value="GA"<% If State = "GA" Then Response.Write(" selected=""selected""") %>>Georgia</option>
<option value="HI"<% If State = "HI" Then Response.Write(" selected=""selected""") %>>Hawaii</option>
<option value="ID"<% If State = "ID" Then Response.Write(" selected=""selected""") %>>Idaho</option>
<option value="IL"<% If State = "IL" Then Response.Write(" selected=""selected""") %>>Illinois</option>
<option value="IN"<% If State = "IN" Then Response.Write(" selected=""selected""") %>>Indiana</option>
<option value="IA"<% If State = "IA" Then Response.Write(" selected=""selected""") %>>Iowa</option>
<option value="KS"<% If State = "KS" Then Response.Write(" selected=""selected""") %>>Kansas</option>
<option value="KY"<% If State = "KY" Then Response.Write(" selected=""selected""") %>>Kentucky</option>
<option value="LA"<% If State = "LA" Then Response.Write(" selected=""selected""") %>>Louisiana</option>
<option value="ME"<% If State = "ME" Then Response.Write(" selected=""selected""") %>>Maine</option>
<option value="MD"<% If State = "MD" Then Response.Write(" selected=""selected""") %>>Maryland</option>
<option value="MA"<% If State = "MA" Then Response.Write(" selected=""selected""") %>>Massachusetts</option>
<option value="MI"<% If State = "MI" Then Response.Write(" selected=""selected""") %>>Michigan</option>
<option value="MN"<% If State = "MN" Then Response.Write(" selected=""selected""") %>>Minnesota</option>
<option value="MS"<% If State = "MS" Then Response.Write(" selected=""selected""") %>>Mississippi</option>
<option value="MO"<% If State = "MO" Then Response.Write(" selected=""selected""") %>>Missouri</option>
<option value="MT"<% If State = "MT" Then Response.Write(" selected=""selected""") %>>Montana</option>
<option value="NE"<% If State = "NE" Then Response.Write(" selected=""selected""") %>>Nebraska</option>
<option value="NH"<% If State = "NH" Then Response.Write(" selected=""selected""") %>>New Hampshire</option>
<option value="NJ"<% If State = "NJ" Then Response.Write(" selected=""selected""") %>>New Jersey</option>
<option value="NM"<% If State = "NM" Then Response.Write(" selected=""selected""") %>>New Mexico</option>
<option value="NY"<% If State = "NY" Then Response.Write(" selected=""selected""") %>>New York</option>
<option value="NV"<% If State = "NV" Then Response.Write(" selected=""selected""") %>>Nevada</option>
<option value="NC"<% If State = "NC" Then Response.Write(" selected=""selected""") %>>North Carolina</option>
<option value="ND"<% If State = "ND" Then Response.Write(" selected=""selected""") %>>North Dakota</option>
<option value="OH"<% If State = "OH" Then Response.Write(" selected=""selected""") %>>Ohio</option>
<option value="OK"<% If State = "OK" Then Response.Write(" selected=""selected""") %>>Oklahoma</option>
<option value="OR"<% If State = "OR" Then Response.Write(" selected=""selected""") %>>Oregon</option>
<option value="PA"<% If State = "PA" Then Response.Write(" selected=""selected""") %>>Pennsylvania</option>
<option value="RI"<% If State = "RI" Then Response.Write(" selected=""selected""") %>>Rhode Island</option>
<option value="SC"<% If State = "SC" Then Response.Write(" selected=""selected""") %>>South Carolina</option>
<option value="SD"<% If State = "SD" Then Response.Write(" selected=""selected""") %>>South Dakota</option>
<option value="TN"<% If State = "TN" Then Response.Write(" selected=""selected""") %>>Tennessee</option>
<option value="TX"<% If State = "TX" Then Response.Write(" selected=""selected""") %>>Texas</option>
<option value="UT"<% If State = "UT" Then Response.Write(" selected=""selected""") %>>Utah</option>
<option value="VT"<% If State = "VT" Then Response.Write(" selected=""selected""") %>>Vermont</option>
<option value="VA"<% If State = "VA" Then Response.Write(" selected=""selected""") %>>Virginia</option>
<option value="WA"<% If State = "WA" Then Response.Write(" selected=""selected""") %>>Washington</option>
<option value="WV"<% If State = "WV" Then Response.Write(" selected=""selected""") %>>West Virginia</option>
<option value="WI"<% If State = "WI" Then Response.Write(" selected=""selected""") %>>Wisconsin</option>
<option value="WY"<% If State = "WY" Then Response.Write(" selected=""selected""") %>>Wyoming</option>

                                                  </select>

looking forward to your reply

1. Before posting, store the value (in this case the selectedIndex of the SELECT) you want in a hidden control (INPUT TYPE = "Hidden" etc...)
2. Accept the value in the page accepting the post in a Server side variable.
3.When you return to the original page, obtain the server variable in a client side variable using javascript (var Clientvar = <%=ServerVar%> ; )
4. Set the selectedIndex of the SELECT as the client variable (<<Select_Name>>.selectedIndex = Clientvar)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.