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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically populated option box question

Status
Not open for further replies.

Tread42

MIS
Feb 5, 2002
151
0
0
US
Is this possible to do? In another page I've captured a particular customer type say they have cust=1 or cust=2. What I want to do is that if cust=2 then they can't see two values from a drop-down list box. So cust 1 see values "A,B,C,D" in the drop-down and cust 2 sees "A,B". Does anyone know how to do this with an option/list box?

Thanks Regards,
Tread42
 
Hi Tread42,

Yes, definitely doable.

Here is an example I did for an ASP page.

I only wanted to populate the year-box with years that actually had data in the table. Why show 2000 or 2003 in the select box if there is no data in the table for those years... right? What you want to do is similar...

Good luck, john

It is written in VBscript:

<%
'Build the dropdown box entries
'Retrieve all unique year values in the LoadHist table so we can populate the YR dropdown box

sql = &quot;SELECT DISTINCT year(DateClosed) As YearClosed FROM LoadHist ORDER BY YearClosed&quot;


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

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


'Add entries to the selection box for each year we have accumulated Load history for
%>


<SELECT NAME=&quot;YR&quot; size=&quot;1&quot; onChange=&quot;Loads.submit()&quot;>
<option>Select a year</option>

<%
Do While NOT rs.eof
%>


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

<%

rs.MoveNext()
Loop

'...end of section that builds the dropdown box
%>
</SELECT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top