473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with dropdown lists: one disappears after the previous one is selected

I really hope this makes sense to someone because I really need some assistance with this:

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:

Expand|Select|Wrap|Line Numbers
  1. <table width="100%" cellpadding="2" cellspacing="0" border="0">
  2.         <tr>
  3.                 <td>
  4.                 Select a Source:
  5.                 <select name="cboSource" id="cboSource" onchange="cboSourceChange()">
  6.             <option value="0"></option>
  7.         <%    While Not rsSource.EOF%>
  8.         <option value="<%=rsSource("iParameterId")%>"
  9.  <%if cLng(rsSource("iParameterId")) = cLng(iSource) then response.Write " Selected " %>>
  10.     <%=rsSource("vchParameterDesc")%>
  11.             </option>
  12.             <%    rsSource.MoveNext
  13.             wend
  14.                 %>
  15.         </select>
  16.         &nbsp;(<%=iSource%>)
  17.     </td>
  18.     </tr>
  19.     <tr>
  20.     <td>
  21.             <%    if iSource <> "0" then %>
  22.                 Select a Source Sub 1:
  23.             <%        if not rsSub1.EOF then %>
  24.             <select name="cboSub1" id="cboSub1" onchange="cboSub1Change()">
  25.             <option value="0"></option>
  26.                 <option value="1">ALL</option>
  27.             <%    While Not rsSub1.EOF%>
  28.                 <option value="<%=rsSub1("iParameterId")%>" 
  29. <%if cLng(rsSub1("iParameterId")) = cLng(iSub1) then response.Write " Selected " %>>
  30.     <%=rsSub1("vchParameterDesc")%>
  31.         </option>
  32.             <%
  33.     rsSub1.MoveNext
  34.         wend
  35.                 %>
  36.         </select>
  37.         &nbsp;(<%=iSub1%>)
  38.     <%        else 
  39.     response.Write "No Source Sub 1 options defined." 
  40.         end if %>
  41.         </td>
  42.             </tr>
  43.                 <tr>
  44.             <td>
  45.         <%        if iSub1 <> "0" then %>
  46.         Select a Source Sub 2:
  47.         <%            if not rsSub2.EOF then %>
  48.                 <select name="cboSub2" id="cboSub2" onchange="cboSub2Change()">
  49.                     <option value="0"></option>
  50.     <%                While Not rsSub2.EOF%>
  51.         <option value="<%=rsSub2("iParameterId")%>" 
  52. <%if cLng(rsSub2("iParameterId")) = cLng(iSub2) then response.Write " Selected " %>>
  53.     <%=rsSub2("vchParameterDesc")%>
  54.         </option>
  55.             <%rsSub2.MoveNext
  56.             wend
  57.                         %>
  58.         </select>
  59.         nbsp;(<%=iSub2%>)
  60.             <%    else 
  61.         response.Write "No Source Sub 2 options defined." 
  62.             end if %>
  63.             </td>
  64.                 </tr>
  65.                 <tr>
  66.             <td>
  67.         <%            if iSub2 <> "0" then %>
  68.             Select a Source Sub 3:
  69.         <%                if not rsSub3.EOF then %>
  70.         <select name="cboSub3" id="cboSub3" onchange="cboSub3Change()">
  71.                 <option value="0"></option>
  72.             <%                    While Not rsSub3.EOF%>
  73.         <option value="<%=rsSub3("iParameterId")%>"
  74. <%if cLng(rsSub3("iParameterId")) = cLng(iSub3) then response.Write " Selected " %>>
  75. <%=rsSub3("vchParameterDesc")%>
  76.         </option>
  77.     <%
  78.     rsSub3.MoveNext
  79.     wend
  80.         %>
  81.         </select>
  82.     &nbsp;(<%=iSub3%>)
  83.     <%        else 
  84.         response.Write "No Source Sub 3 options defined." 
  85.     end if %>
  86.     <%            end if 
  87.     end if 
  88. end if %>
  89.             </td>
  90.         </tr>
  91.         </table>
Expand|Select|Wrap|Line Numbers
  1. ' Get a recordset of the primary sources for an Onyx Sales Opportunity
  2. sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _
  3.         "where iReferenceId = 11 and tiRecordStatus = 1 and iParentId = 3 order by vchParameterDesc"
  4.  
  5. Set rsSource = Server.CreateObject("ADODB.Recordset")
  6. rsSource.Open sql, cnOnyx, 0, 1
  7. ' If a source was selected, get a list of the sub source 1 options.
  8. If iSource <> "0" then    
  9.     sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _
  10.             "where iReferenceId = 641 and tiRecordStatus = 1 and iParentId = " & iSource & _
  11.             "  order by vchParameterDesc"
  12.     Set rsSub1 = Server.CreateObject("ADODB.Recordset")
  13.     rsSub1.Open sql, cnOnyx, 0, 1    
  14.         ' If a sub source 1 is selected, get a list of sub source 2 options.
  15.  
  16.     'M006A Begin
  17.     If iSub1 <> "0" then
  18.  If iSub1 = "1" then
  19.   sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _
  20.                 "where iReferenceId = 642 and tiRecordStatus = 1" & _
  21.                 " order by vchParameterDesc"
  22.  else
  23.          sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _
  24.                 "where iReferenceId = 642 and tiRecordStatus = 1 and iParentId = " & iSub1 & _
  25.                 " order by vchParameterDesc"
  26.  
  27.  end if
  28.  
  29.         Set rsSub2 = Server.CreateObject("ADODB.Recordset")
  30.         rsSub2.Open sql, cnOnyx, 0, 1
  31.                   Set rsSub2 = Server.CreateObject("ADODB.Recordset")
  32.        rsSub2.Open sql, cnOnyx, 0, 1  
  33.  
  34. if not rsSub2.eof then
  35. rsSub2.MoveFirst
  36.  
  37. end if
  38.  
  39.   'end if
  40.   'M006A End
  41.         ' If a sub source 2 is selected, get a list of sub source 3 options.
  42.         If iSub2 <> "0" then
  43.  
  44.             sql = "Select iParameterId, vchParameterDesc from ReferenceDefinition " & _
  45.                     "where iReferenceId = 643 and tiRecordStatus" & _
  46.                     "order by vchParameterDesc"
  47.  
  48.             Set rsSub3 = Server.CreateObject("ADODB.Recordset")
  49.             rsSub3.Open sql, cnOnyx, 0, 1
  50.  
  51.         End If   
  52.         'response.Write(sql)
  53.                   '  response.End()
  54.     End If   
  55.  
  56. End If 
May 28 '10 #1
1 1426
jhardman
3,406 Expert 2GB
This isn't really an asp question, it all depends on the javascript functions (cboSub1Change etc) that open the selects. I bet if you look carefully you aren't tracking the names of the controls carefully.

Anyway, if you need more help, I would post in the javascript forum.

Jared
May 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
2
by: Tony Grider | last post by:
I am trying to find a way to create dependent dropdown lists in C# The old way I knew involved javascript and will no longer work in the new design. I need for each list to be database driven (data...
0
by: Mike O. | last post by:
MS Access 2003 "filter by form" has drop down lists that allow the user to select values for each field to filter by. However, once some values are selected,the remaining dropdown lists remain the...
0
by: Henke | last post by:
Hi, I have done some research about my problem I have when using the "back button" in IE to go back to a page with two dropdown lists. The both dropdown lists are populated with data. The...
2
by: Chris Becker | last post by:
This is my attempt to rephrase a question I asked earlier that got no response. I suspect it was my poor/unplanned wording. Here is another attempt: I have a form with some drop down lists. I...
0
by: Anthony | last post by:
So I've got three dropdowns in a datagrid footer (to add records). I need them to cascade, in the first one I have three choices, in the second one I have anywhere from 3 to 10 choices, depending...
1
by: Ed Chiu | last post by:
Hi, I have 2 dropdown lists on an ASP.Net page, the first is a list of states of US, the second is City list. When user selects a state, the web page does a postback, create a DB connection and...
1
by: cgian31 | last post by:
I have implemented a website where in a page are represented the data of one record, using cascade dropdown lists in 2 levels, within the same page/record. According to the selection in the...
2
by: Lair | last post by:
I am creating a page that has three to four databound dropdown lists. Each one is has different data sometimes from the same table but with a different where clause. What is the best way to...
1
by: eddie23 | last post by:
Hi group. we've an ASP.net application. there are dropdown lists all over it. we use IE6 SP2 here in work. When the dropdown is accessed by someone logged in as a local admin to the XP workstation...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.