Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a DropDown Box from Table 1

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hello again,

I am trying to insert entries into my drop-down box, based on the values in my database. I know the SQL SELECT statement is working.... but no entries are getting put into the dropdown box. Click the down arrow in the box and there are not any options to select.

Can anyone help me with the <option value= portion of this ASP?

Thanks again. Several of you have helped me with various problems and I appreciate it.

John
_____________________________________________________

sql = &quot;SELECT DISTINCT DateClosed FROM LoadHist ORDER BY DateClosed&quot;

set rs = createobject(&quot;adodb.recordset&quot;)

rs.open sql,conn, adOpenStatic, adLockReadOnly, adCmdText
%>

<SELECT NAME=&quot;YR&quot; size=&quot;1&quot;>
<option>Select a year</option>

<%
Do While NOT rs.eof
%>

<option value=&quot;<%=(rs.Fields.Item(&quot;DateClosed&quot;).Value)%>&quot;>
</option>
</SELECT>
<%

rs.MoveNext()
Loop

%>
 
hi John

See if this woeks for you

<%
Do While NOT rs.eof
%>

<option value=&quot;<%rs('DateClosed')%>&quot;>
</option>
</SELECT>
<%

rs.MoveNext()
Loop

%>

Mark
 
Thanks Mark,

I got...
Microsoft VBScript compilation error '800a03ea'

Syntax error

/DirShip/BarChart/SelectMonth.asp, line 40

rs('DateClosed')
---^

Next, i tried.... <option value=&quot;<%=(rs.Fields.Item('DateClosed').Value)%>&quot;>

Also got a syntax error

Thanks, John


 
You are only setting the hidden value, not the text that is displayed to the user. Instead of this:

<option value=&quot;<%=(rs.Fields.Item(&quot;DateClosed&quot;).Value)%>&quot;>
</option>


Try:

<option value=&quot;<%=rs.Fields(&quot;DateClosed&quot;)%>&quot;>
<%=rs.Fields(&quot;DateClosed&quot;)%>
</option>
 
Thanks JuanitaC,

I think we are getting close.....

When I try your suggestion:

<option value=&quot;<%=rs.Fields(&quot;DateClosed&quot;)%>&quot;>
<%=rs.Fields(&quot;DateClosed&quot;)%>
</option>

The first date gets placed into the dropdown box, but all the other dates (there are dozens) are shown outside the box.. like this:

option value=&quot;5/22/02 4:28:07 PM&quot;> 5/22/02 4:28:07 PM option value=&quot;5/22/02 5:39:27 PM&quot;> 5/22/02 5:39:27 PM option value=&quot;5/22/02 6:17:45 PM&quot;> 5/22/02 6:17:45 PM option value=&quot;5/22/02 6:36:52 PM&quot;> 5/22/02 6:36:52 PM option value=&quot;5/22/02 6:39:41 PM&quot;> 5/22/02 6:39:41 PM option value=&quot;5/22/02 7:16:42 PM&quot;>


Thanks for your idea. John
 
I finally figured it out....


The </SELECT> was up too high in my code. When I moved it to after the Lop it works, all entries are now inside the box.

So now I have Loop
%>
</SELECT>


Thanks to everyone who contributed. And a star to JuanitaC.

John


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top