CodeAve.com CodeAve.com - ASP - Read/Write
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Dropdown Menus: Making the Right One Appear on Top
Dropdown menus are a great way to allow for "fixed" user input.  Making sure the correct option always appears on top is as easy as adding a couple of if then tautologies. In this example we have seventeen options (16 U.S. States and one option for Select A State).  Depending on user input (or lack there of) the appropriate option is selected as the one to appear on top.
View the Output
Text View
Print View
Mail this Link
Download the Code

<% u_state=request.form("u_state") %>
<form action="<%= request.servervariables("script_name") %>" method="post">
<select name="u_state">
<option<% if u_state="" then %> selected<% end if %>> Select a State </option>
<option<% if u_state="AL" then %> selected<% end if %> value="AL"> Alabama </option>
<option<% if u_state="AR" then %> selected<% end if %> value="AR"> Arkansas </option>
<option<% if u_state="CA" then %> selected<% end if %> value="CA"> California </option>
<option<% if u_state="CO" then %> selected<% end if %> value="CO"> Colorado </option>
<option<% if u_state="CT" then %> selected<% end if %> value="CT"> Connecticut </option>
<option<% if u_state="DE" then %> selected<% end if %> value="DE"> Delaware </option>
<option<% if u_state="MD" then %> selected<% end if %> value="MD"> Maryland </option>
<option<% if u_state="NE" then %> selected<% end if %> value="NE"> Nebraska </option>
<option<% if u_state="NH" then %> selected<% end if %> value="NH"> New Hampshire </option>
<option<% if u_state="NJ" then %> selected<% end if %> value="NJ"> New Jersey </option>
<option<% if u_state="NY" then %> selected<% end if %> value="NY"> New York </option>
<option<% if u_state="PA" then %> selected<% end if %> value="PA"> Pennsylvania </option>
<option<% if u_state="TN" then %> selected<% end if %> value="TN"> Tennessee </option>
<option<% if u_state="TX" then %> selected<% end if %> value="TX"> Texas </option>
<option<% if u_state="VA" then %> selected<% end if %> value="VA"> Virginia </option>
</select>
<input type="submit" value="Submit">
</form>
<p>
<% if u_state = "" then %>
Either this is the first time the page is being used<br>
or the user selected the Select A State choice.
<% else %>
<%= u_state %> was selected by the user.
<% end if %>
</p>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3