Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dynamic default value a menu box troubles

Reply
Thread Tools

Dynamic default value a menu box troubles

 
 
djjohnst
Guest
Posts: n/a
 
      05-14-2007
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?

 
Reply With Quote
 
 
 
 
djjohnst
Guest
Posts: n/a
 
      05-14-2007
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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
div box questions; float text around a box, fit box to image size Gnarlodious HTML 4 05-05-2010 11:30 AM
Form box menu - force the drop down menu Krustov Javascript 2 12-05-2006 08:05 PM
2.0 Menu control : Can the dynamic popup menu items be divided into 2 columns instead of 1? Perry Loh ASP .Net Web Controls 0 03-24-2006 04:44 AM
Dynamic Menu with SOThink Menu? Lasse Edsvik ASP General 0 02-13-2006 10:34 AM
How to create dynamic menu with user roles (Treeview menu) naijacoder naijacoder ASP .Net Web Controls 0 09-27-2004 09:33 AM



Advertisments