Advertisement

08.28.2008 at 08:00AM PDT, ID: 23685753 | Points: 500
[x]
Attachment Details

Filling select box

Asked by flfmmqp in Active Server Pages (ASP), JavaScript

I have two dropdown boxes.  I want to filter one drop down box depending on what is selected by the other.  So a user comes in and selects a value in the divison ("ddlDiv") list.  Based on what this value is it then it goes to the Access database and filters on this value and populates the markets list ("ddlMarket").

Currently I would populate the ddlMarket like this where MSO is the divisiion and filterMarket is the function on the onchange event on ddlDiv <select id="ddlDiv" style="width: 170px; background-color: yellow;" name="division" onchange="filterMarket()" language="javascript">:

function filterMarket() {
  if(document.CE_EntryInfo.ddlDiv.value==0)
      {
         alert( 'Division value S/B=0 : ' + document.CE_EntryInfo.ddlDiv.value);  
      }
    else
      {
         alert( 'Division value S/B<>0 : ' + document.CE_EntryInfo.ddlDiv.value);          
      }                    
    }



<select id="ddlMarket" style="width: 170px; background-color: yellow;" name="dma">                  
                         <option value="0">-- Select Market --</option>
                        <%                
                            'Dim objConnection, objRS
                              'Create the recordset object
                             
                              Set objRS = Server.CreateObject("ADODB.Recordset")
                              objRS.Open "SELECT Dmas.Division, Dmas.DMAID, Dmas.DMANAME FROM Dmas GROUP BY Dmas.Division, Dmas.DMAID, Dmas.DMANAME HAVING (((Dmas.Division)='MSO')) ORDER BY Dmas.DMANAME;", "dsn=CompEvents"      
                            'SELECT [Timing].[Season] FROM Timing GROUP BY [Timing].[Season] UNION select '-- Select a Season --' as Season  FROM Timing ORDER BY [Timing].[Season];                                               'Loop through the recordset adding each Division to the combo box
                                          Do While Not objRS.EOF

                        %>        
                        <option value="<%=objRS("DMAID")%>"> <%=objRS("DMANAME")%></option>
                        <%
                                                objRS.MoveNext
                                          Loop

                                          'Close and dereference database objects
                                          objRS.Close
                                          Set objRS = Nothing              
                                    Set objConnection = Nothing

                         %>                    
</select>Start Free Trial
[+][-]08.28.2008 at 08:31AM PDT, ID: 22336104

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628