I have a asp page that I am working on that has as many as 4 dropdownlists depending on what I choose in those dropdowns. The 4 dropdowns are named:iSource, iSub1, iSub2, iSub3. To begin I select an item for iSource then iSub1 comes up and I have an option to choose ALL or any of the other items in the recordset. If I choose ALL it will bring up iSub2 which populates everything that I would have chosen for each of the items in iSub1. After selecting ALL and iSub2 dropdown comes up I choose an item from iSub2. This is where the problem happens. Once I select something from iSub2 dropdown it disappears and iSub1 comes back up. What I want it to do once I select something from iSub2 it should show iSub3 dropdown. Based on my code what am I doing incorrectly. I am showing two pieces of code from the page. The first is the html table with each of the dropdowns and the second is the sql recordset statements:
Code:<table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td> Select a Source: <select name="cboSource" id="cboSource" onchange="cboSourceChange()"> <option value="0"></option> <% While Not rsSource.EOF%> <option value="<%=rsSource("iParameterId")%>" <%if cLng(rsSource("iParameterId")) = cLng(iSource) then response.Write " Selected " %>> <%=rsSource("vchParameterDesc")%> </option> <% rsSource.MoveNext wend %> </select> (<%=iSource%>) </td> </tr> <tr> <td> <% if iSource <> "0" then %> Select a Source Sub 1: <% if not rsSub1.EOF then %> <select name="cboSub1" id="cboSub1" onchange="cboSub1Change()"> <option value="0"></option> <option value="1">ALL</option> <% While Not rsSub1.EOF%> <option value="<%=rsSub1("iParameterId")%>" <%if cLng(rsSub1("iParameterId")) = cLng(iSub1) then response.Write " Selected " %>> <%=rsSub1("vchParameterDesc")%> </option> <% rsSub1.MoveNext wend %> </select> (<%=iSub1%>) <% else response.Write "No Source Sub 1 options defined." end if %> </td> </tr> <tr> <td> <% if iSub1 <> "0" then %> Select a Source Sub 2: <% if not rsSub2.EOF then %> <select name="cboSub2" id="cboSub2" onchange="cboSub2Change()"> <option value="0"></option> <% While Not rsSub2.EOF%> <option value="<%=rsSub2("iParameterId")%>" <%if cLng(rsSub2("iParameterId")) = cLng(iSub2) then response.Write " Selected " %>> <%=rsSub2("vchParameterDesc")%> </option> <%rsSub2.MoveNext wend %> </select> nbsp;(<%=iSub2%>) <% else response.Write "No Source Sub 2 options defined." end if %> </td> </tr> <tr> <td> <% if iSub2 <> "0" then %> Select a Source Sub 3: <% if not rsSub3.EOF then %> <select name="cboSub3" id="cboSub3" onchange="cboSub3Change()"> <option value="0"></option> <% While Not rsSub3.EOF%> <option value="<%=rsSub3("iParameterId")%>" <%if cLng(rsSub3("iParameterId")) = cLng(iSub3) then response.Write " Selected " %>> <%=rsSub3("vchParameterDesc")%> </option> <% rsSub3.MoveNext wend %> </select> (<%=iSub3%>) <% else response.Write "No Source Sub 3 options defined." end if %> <% end if end if end if %> </td> </tr> </table>Code:' Get a recordset of the primary sources for an Onyx Sales Opportunity sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _ "where iReferenceId = 11 and tiRecordStatus = 1 and iParentId = 3 order by vchParameterDesc" Set rsSource = Server.CreateObject("ADODB.Recordset") rsSource.Open sql, cnOnyx, 0, 1 ' If a source was selected, get a list of the sub source 1 options. If iSource <> "0" then sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _ "where iReferenceId = 641 and tiRecordStatus = 1 and iParentId = " & iSource & _ " order by vchParameterDesc" Set rsSub1 = Server.CreateObject("ADODB.Recordset") rsSub1.Open sql, cnOnyx, 0, 1 ' If a sub source 1 is selected, get a list of sub source 2 options. 'M006A Begin If iSub1 <> "0" then If iSub1 = "1" then sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _ "where iReferenceId = 642 and tiRecordStatus = 1" & _ " order by vchParameterDesc" else sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _ "where iReferenceId = 642 and tiRecordStatus = 1 and iParentId = " & iSub1 & _ " order by vchParameterDesc" end if Set rsSub2 = Server.CreateObject("ADODB.Recordset") rsSub2.Open sql, cnOnyx, 0, 1 Set rsSub2 = Server.CreateObject("ADODB.Recordset") rsSub2.Open sql, cnOnyx, 0, 1 if not rsSub2.eof then rsSub2.MoveFirst end if 'end if 'M006A End ' If a sub source 2 is selected, get a list of sub source 3 options. If iSub2 <> "0" then sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _ "where iReferenceId = 643 and tiRecordStatus" & _ "order by vchParameterDesc" Set rsSub3 = Server.CreateObject("ADODB.Recordset") rsSub3.Open sql, cnOnyx, 0, 1 End If 'response.Write(sql) ' response.End() End If End If




Bookmarks