By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,659 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,659 IT Pros & Developers. It's quick & easy.

Drop list that displays the relevant data

P: 1
Hi,

I am wanting to create a drop list that displays categories, if a category is selected it posts to the same page all the listings for that category. I am using dreamweaver so just giving code or telling me to google it does not help me. Surely there is a tutorial or something for this simple operation. I have placed, I think the problem area in Bold type.

I have included the code which might help:

Expand|Select|Wrap|Line Numbers
  1. Recordset:
  2. <head>
  3. <%
  4. Dim Rs
  5. Dim Rs_cmd
  6. Dim Rs_numRows
  7.  
  8. Set Rs_cmd = Server.CreateObject ("ADODB.Command")
  9. Rs_cmd.ActiveConnection = MM_Conn_STRING
  10. Rs_cmd.CommandText = "SELECT * FROM tblCategory" 
  11. Rs_cmd.Prepared = true
  12.  
  13. Set Rs = Rs_cmd.Execute
  14. Rs_numRows = 0
  15. %>
  16. <%
  17. Dim RsData
  18. Dim RsData_cmd
  19. Dim RsData_numRows
  20.  
  21. Set RsData_cmd = Server.CreateObject ("ADODB.Command")
  22. RsData_cmd.ActiveConnection = MM_Conn_STRING
  23. RsData_cmd.CommandText = "SELECT * FROM tblEquip" 
  24. RsData_cmd.Prepared = true
  25.  
  26. Set RsData = RsData_cmd.Execute
  27. RsData_numRows = 0
  28. %>
  29. </head>
  30.  
  31. Form with Drop Down:
  32.  
  33. <body>
  34. <form action="equiplist1.asp" method="post" name="form1" target="_parent">
  35.           <table width="990" border="0" align="center">
  36.             <tr>
  37.               <td width="17">&nbsp;</td>
  38.               <td width="194" align="right" class="blockText">Equipment Category</td>
  39.               <td width="165" align="center">
  40.              label for="CategoryBox"></label>
  41.                 <select name="CategoryBox" class="textboxstyleMed" id="CategoryBox" tabindex="1" #nChange="submit()" value="(Request.Session("categoryID"))" size="1">
  42.                   <option value="" <%If (Not isNull((Rs.Fields.Item("categoryID").Value))) Then If ("" = CStr((Rs.Fields.Item("categoryID").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%>>Please Select</option>
  43.                   <%
  44. While (NOT Rs.EOF)
  45. %>
  46. <option value="<%=(Rs.Fields.Item("categoryID").Value)%>" <%If (Not isNull((Rs.Fields.Item("categoryID").Value))) Then If (CStr(Rs.Fields.Item("categoryID").Value) = CStr((Rs.Fields.Item("categoryID").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Rs.Fields.Item("categoryType").Value)%></option>
  47.                   <%
  48.   Rs.MoveNext()
  49. Wend
  50. If (Rs.CursorType > 0) Then
  51.   Rs.MoveFirst
  52. Else
  53.   Rs.Requery
  54. End If
  55. %>
  56.                 </select>
  57. </body>
Aug 23 '11 #1
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
Although your solution can use some ASP, you will need some ajax or javascript for what you are describing. I have seen this type of effect done three different ways:
1- use javascript to post the form as soon as they make the first selection. Then you send them the same page (hopefully fast enough that they only see a very short lag) with their first selection saved and the next selection populated with the specific sub-categories or whatever.
2- use ajax to communicate the first choice back to the server, then rebuild the second choice on the fly - this is probably the most popular nowadays.
3- If you're not talking about dozens of options, then you might consider building the page with all of the options from the start, but hide them. Then when the user makes his first choice, it is only a matter of hiding/unhiding the various components with javascript. This is probably the fastest option from the end-user's point of view.

Let me know if this helps.

Jared
Aug 29 '11 #2

Post your reply

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