Dynamic default value a menu box troubles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • djjohnst

    Dynamic default value a menu box troubles

    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"><se lect name="WorkshopT ype"
    id="WorkshopTyp e">

    <% if WorkshopType = "Informatio n Session" then
    %>
    <option value="Informat ion Session" selected>Inform ation Session</
    option>
    <option value="Intervie w Practice Clinic">Intervi ew
    Practice Clinic</option>
    <option value="Senior Job Search Seminar">Senior Job
    Search Seminar</option>
    <% elseif WorkshopType = "Interview Practice Clinic" then
    %>
    <option value="Informat ion Session">Inform ation Session</option>
    <option value="Intervie w Practice Clinic"
    selected>Interv iew Practice Clinic</option>
    <option value="Senior Job Search Seminar">Senior Job
    Search Seminar</option>
    <% elseif WorkshopType = "Senior Job Search Seminar" then
    %>
    <option value="Informat ion Session">Inform ation Session</option>
    <option value="Intervie w Practice Clinic">Intervi ew
    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="WorkshopM onth" id="WorkshopMon th">
    <option Value = "<%response.Wri te(WorkshopMont h)%>" 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?

  • djjohnst

    #2
    Re: Dynamic default value a menu box troubles

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

    <td width="103">Mon th
    <select name="WorkshopM onth" id="WorkshopMon th">
    <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>

    Comment

    Working...