SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with dropdown list

    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&#37;" 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>
    		&nbsp;(<%=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>
    		&nbsp;(<%=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>
    	&nbsp;(<%=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

  2. #2
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone with any ideas?

  3. #3
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure if anyone can debug that for you.

    You'll need to step through the code line by line and debug where it is going bad.

    add some outputs where you think it should be appearing and keep at it until you can narrow down the problem.

    then someone may be able to help

  4. #4
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What am I supposed to debug? Also there is no way to do that in asp classic except to do response.write. The problem is getting into the If iSub2 area of the code. I tried to do a response.write and it doesn't get to that point. I can write to the iSub1 but not iSub2. I don't get any error messages at all.

  5. #5
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have to keep going back into the code until you find a place where the code works and where it doesn't.

    Yes, response.write is the common means of debugging.

    A more elaborate tool, ASP studio, is available here

    http://www.aspdevelope.com/

    if you want to take the time to learn it....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •