Dynamic default value a menu box troubles

D

djjohnst

I am trying to fill out a form from a record set and have a few menu
boxes that have a static list of values. I want to fill out the
default value with the variable from the recordset. The one solution i
thought of is as follows:

<td colspan="3"><select name="WorkshopType"
id="WorkshopType">

<% if WorkshopType = "Information Session" then
%>
<option value="Information Session" selected>Information Session</
option>
<option value="Interview Practice Clinic">Interview
Practice Clinic</option>
<option value="Senior Job Search Seminar">Senior Job
Search Seminar</option>
<% elseif WorkshopType = "Interview Practice Clinic" then
%>
<option value="Information Session">Information Session</option>
<option value="Interview Practice Clinic"
selected>Interview Practice Clinic</option>
<option value="Senior Job Search Seminar">Senior Job
Search Seminar</option>
<% elseif WorkshopType = "Senior Job Search Seminar" then
%>
<option value="Information Session">Information Session</option>
<option value="Interview Practice Clinic">Interview
Practice Clinic</option>
<option value="Senior Job Search Seminar"
selected>Senior Job Search Seminar</option>
<%end if%>

</select>

This works great. However, this menu only had 3 options so it was easy
to implement. I also have menus with 31 different options. The way i
came up with was to do something like this:

<select name="WorkshopMonth" id="WorkshopMonth">
<option Value = "<%response.Write(WorkshopMonth)%>" selected><
%response.Write(WorkshopMonth)%></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

Yes, this works, but it lists the default value twice. This isn't the
end of the world but I would like to clean it up a bit. Is there a
better way to do this?
 
D

djjohnst

Nevermind, I guess the easiest way for me to do it is by doing it like
this:

<td width="103">Month
<select name="WorkshopMonth" id="WorkshopMonth">
<option value="1" <%if WorkshopMonth = 1 then
response.Write(" selected")%>>1</option>
<option value="2" <%if WorkshopMonth = 2 then
response.Write(" selected")%>>2</option>
<option value="3" <%if WorkshopMonth = 3 then
response.Write(" selected")%>>3</option>
<option value="4" <%if WorkshopMonth = 4 then
response.Write(" selected")%>>4</option>
<option value="5" <%if WorkshopMonth = 5 then
response.Write(" selected")%>>5</option>
<option value="6" <%if WorkshopMonth = 6 then
response.Write(" selected")%>>6</option>
<option value="7" <%if WorkshopMonth = 7 then
response.Write(" selected")%>>7</option>
<option value="8" <%if WorkshopMonth = 8 then
response.Write(" selected")%>>8</option>
<option value="9" <%if WorkshopMonth = 9 then
response.Write(" selected")%>>9</option>
<option value="10" <%if WorkshopMonth = 10 then
response.Write(" selected")%>>10</option>
<option value="11" <%if WorkshopMonth = 11 then
response.Write(" selected")%>>11</option>
<option value="12" <%if WorkshopMonth = 12 then
response.Write(" selected")%>>12</option>
</select>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top