SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with multiple dropdown box selection..

    Hi
    I have multiple drop down boxes .After selecting each item in drop down boxes it will display the data from database..

    Here i am successfully displaying the drop down boxes and problem with the data retrieving..

    here is my sample code:
    Code ASP:
    <form method="post" action="test4.asp">
    <div align="center">
     
    <table align="Center">
    <tr><td>Menu Type</td>&nbsp;
    <%
    OpenSQLConn
    SQL = "Select * from menu order by m_id"
    Set rs = Conn.Execute(SQL)%>
    <td> <select name="optm">
         <option value="">Please Choose</option>
        	<% Do While Not rs.EOF %>
        <option value="<%=rs("mid")%>"><%=rs("mid")%><%=rs("mtype")%>
        </option>
    	<%
    	rs.MoveNext
    	Loop
    	%>
    </select></td></tr>
    <tr><td> Size</td>
    <%
    SQL = "Select * from size order by sid"
    Set rs = Conn.Execute(SQL)%>
     <td> <select name="opts">
            <option value="">Please Choose</option>
            <% Do While Not rs.EOF %>
           <option value="<%=rs("sid")%>"><%=rs("sid")%><%=rs("size")%>
          </option>
          <%
          rs.MoveNext
         Loop
          %>
       </select></td></tr>
     
     
    </table>
    <input type="submit" value="Show Items " name="ssubmit" />

    Code ASP:
    <%
    	OpenSQLConn
    	if optm <> "" then 
         	if opts <> "" then 
    	Sql1="Select * from master where mid='" & optm & "' and sid='" opts&"'"
       			Set rs=Conn.Execute(sql1)
    %>
    <table width="60%" cellspacing="0" cellpadding="2" border="1">
    <%
    		do until rs.EOF
       		response.write("<tr>")
       		response.write("<td>" & rs("mid") & "</td>")
       		response.write("<td>" & rs("sid") & "</td>")
       		response.write("<td>" & rs("mtype") & "</td>")
       		response.write("<td>" & rs("size") & "</td>")
       		response.write("<td>" & rs("measure") & "</td>")
     
       		response.write("</tr>")
       		rs.MoveNext
    		loop
    		rs.close
    		Conn.Close
     
    %>
    </table>
     
    <%		
    end if
    end if
     %>
    </form>


    can any one know where the error drawn.. I am unable to find out the error..is it with my sql statement or mulyiple if statements..

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How are you getting the values for the variable optm and opts?

    Where are your Request.Form() commands?
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am getting values from database for optm and opts..

    optm from dtabase table menu
    opts from table size..

    these two are different tables..

    and my "master" table is refereing the primary key columns from these table..

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lucky20 View Post
    I am getting values from database for optm and opts..
    No you're not. Your code is CHECKING the values of optm and opts ...
    Code:
        if optm <> "" then 
            if opts <> "" then
    ... but nowhere are you DEFINING (i.e. getting the values of) optm and opts - at least not in the code you have posted. (You are creating the <option> list for optm and opts, but you're not showing how you are getting the <option> VALUES when the form is submitted. If you don't get the values then the code I copied above will ALWAYS evaluate to False, so your table will never be displayed).
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes Ian. you are right..
    But how can i check those values..
    a bit confusion..

    I never did any thing like this?So i don't have any clue..

  6. #6
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code ASP:
    <%
    optm = Request.Form("optm")
    opts = Request.form("opts")
        OpenSQLConn
        if optm <> "" then 
            if opts <> "" then 
     ' Rest of ur code
    %>

    try it, maybe that would help

  7. #7
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No ..I am getting an error ..
    May be it 's not the way to do it..

  8. #8
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ Ian and Ulthane..

    I have corrected it..
    Got the solution..

    Problem with the if statements ..
    I am passing empty values like Ian said..
    Now its working..


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
  •