Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
list box Posted by mybren on 15 Dec 2001 at 7:54 AM
Hi,
I've created a list box in ASP that's populated with the 12 months. Upon user selection, I will save the month.

        <select name="month" size="1">	
          <option value="3">March</option>
          <option value="4">April</option>
          <option value="5">May</option>
          <option value="6">June</option>
        </select>


The user can also modify the value in the future. Here's where my problem crops up.

How do I "select" the month name that was previously saved into the database?

The only method I could find was:


<%If mth = "1" Then%><option value="1" selected>January<%Else%><option value="1">January<%End If%></option>



Does anyone have a simpler method because I have many listboxes!!

Thanks in advance.
Report
Re: list box Posted by VKR on 17 Dec 2001 at 12:51 AM

: <%
'--- Get the value from the Database. Now I had taken the value as static
DOBdd = "5"
%>
<form name="theform">
<select name="month" size="1">
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
</select>
<script language=javascript>
document.theform.month.value="<%=dobdd%>"
</script>
</form>

Report
Re: list box Posted by sternkraft1107 on 17 Dec 2001 at 7:10 AM
: Hi,
: I've created a list box in ASP that's populated with the 12 months. Upon user selection, I will save the month.
:
:
:         <select name="month" size="1">	
:           <option value="3">March</option>
:           <option value="4">April</option>
:           <option value="5">May</option>
:           <option value="6">June</option>
:         </select>
: 

:
: The user can also modify the value in the future. Here's where my problem crops up.
:
: How do I "select" the month name that was previously saved into the database?
:
: The only method I could find was:
:
:
: 
: <%If mth = "1" Then%><option value="1" selected>January<%Else%><option value="1">January<%End If%></option>
: 
: 

:
: Does anyone have a simpler method because I have many listboxes!!
:
: Thanks in advance.
:
------------------------------------------------------------
You could also use a for loop for the months and then set an array with the months in it.

Dim month(11)
month(0) = "January"...-all the way to -...month(11)= "December"
<% for x = 1 to 12 %>
<option value = " <%=x%> "><%=month(x)%></option>
<% Next %>

That'll do it...




 

Recent Jobs