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

Dynamically format drop down text 2

Status
Not open for further replies.

Mdiaz

Programmer
Jul 8, 2002
32
US
Ok folks here is my challenge (and yours I hope). What I really want is some nuddging toward a solution, not so mush the code to accomplish it.

Below is a simple dynamic drop down list that provides a visitor with all of the product line of company Y. Here is the wrench, I want to format the item in the list (grey) that does does not yet have a product associated with it.

In other words, I have productLine table that has a complete product line of stuff that company Y sells. It doesn't mean that a product is listed on the web or in the Products table. The products table, naturally has all of the products with foriegn key to the Productline table.

>>>>>>>>>>>Drop down list<<<<<<<<<<<<<

<form action=&quot;/pages/SearchProductLine.asp&quot; method=&quot;post&quot; name=&quot;frmCat&quot;>

<%'populate drop down list
set rs1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqlstatement=&quot;SELECT * FROM ProductLine Order by SubCat&quot;
rs1.Open sqlstatement, &quot;DSN=somedatabase;UID=;PWD=;&quot;,1,3
%>

<SELECT NAME=&quot;frmSubCat&quot;>
<option value=&quot;&quot;>Product Line</option>
<%while not rs1.EOF%>

<option value=&quot;<%=rs1(&quot;SubCat&quot;)%>&quot;><%=rs1(&quot;SubCat&quot;)%></option>
<%
rs1.MoveNext
wend
rs1.Close%>
</SELECT>

<input type=&quot;submit&quot; name=&quot;frmSubmit1&quot; value=&quot;Find&quot;>
</form>

Thanks for your interest,

Mike Diaz... Mike Diaz
tripletpublishing.com
 
I haven't had much luck with formatting the tecxt of individual items in a drop down box. Have you thought about using text to show this?

Code:
<%'populate drop down list
        set rs1 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
        sqlstatement=&quot;SELECT *, tblProduct.id as Prodid FROM ProductLine LEFT JOIN tblProduct on 
        sqlstatement=sqlstatement & tblProduct.id = tblProductline.id Order by tblProductline.SubCat&quot;
        rs1.Open sqlstatement, &quot;DSN=somedatabase;UID=;PWD=;&quot;,1,3
    %>    
                            
    <SELECT NAME=&quot;frmSubCat&quot;>
        <option value=&quot;&quot;>Product Line</option>
        <%while not rs1.EOF
           if isnull(rs1(&quot;ProdID&quot;)) then%>
              <option value=&quot;<%=rs1(&quot;SubCat&quot;)%>&quot;>***<%=rs1(&quot;SubCat&quot;)%>***</option>
        <%else%>
        
        <option value=&quot;<%=rs1(&quot;SubCat&quot;)%>&quot;><%=rs1(&quot;SubCat&quot;)%></option>
        <% end if 
        rs1.MoveNext
        wend
        rs1.Close%>
    </SELECT>
    
        <input type=&quot;submit&quot; name=&quot;frmSubmit1&quot; value=&quot;Find&quot;>
    </form>

This would show your options as

Product1
***Product2***
Product3

where Product 2 didn't have any product associated with the entry in the product line. You can mess with the SQL statement, I would probably write it as
Code:
select subcat, tblProduct.id As Prodid from...
It is my understanding that this is more effecient than a &quot;SELECT *&quot;. Let me know if this helps
 
In Internet Explorer you can configure the background and text colors of each option:

<form>
<select>
<option>Enabled
<option style=&quot;background-color:silver&quot;>Disabled
</select>
</form> Adam
 
Thanks for the input. I'll try playing with both, although I will need to address the the browser issue. I'm not to fond on browser detection and redirection to broswer specific pages.

Thanks,

Mike Diaz... Mike Diaz
tripletpublishing.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top