?
Solved

Dynamically sort records using Drop Down/ASP

Posted on 2005-05-09
4
Medium Priority
?
224 Views
Last Modified: 2010-04-17
Dear Friends,

Hello. I have a small script that loops to display records in columns on my web page. I need to add a feature that will give the users an option to sort by 'open' or'closed' status, say for instance a drop down field...where you can choose open or closed and click a button then it will show only records by the option you chose in the drop down (OPEN OR CLOSED RECORDS)

<%
  set rs=Server.CreateObject("adodb.Recordset")
   Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database.mdb")

  sqlstmt = "SELECT ID,Name,Number,Product from Users" ( I WILL ADD STATUS HERE)
   rs.open sqlstmt, adoCon
  If rs.eof then
      response.write "<center>There are no records in the database"
        response.write "<br>Please check back later</center>"
        response.end
  Else
  %>

html to display records in columns with headers... ('I'll ADD A DROP DOWN ABOVE so users can choose to display open or closed status records...)


 <%
            rs.MoveNext
        loop
  End If
  %>

Thanks,
Butterfly
0
Comment
Question by:butter_fly
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Bob Lamberson earned 2000 total points
ID: 13965406
>  sqlstmt = "SELECT ID,Name,Number,Product from Users" ( I WILL ADD STATUS HERE)
>    rs.open sqlstmt, adoCon

Not exactly sure what you are asking but is this close to what you are looking for?

sqlstmt = "SELECT ID,Name,Number,Product from Users where yourOpen\Closed field = "" & dropDown.value & "'"


Bob
0
 

Author Comment

by:butter_fly
ID: 13969523
yes, something along those lines..

My current code has a hardcoded select statement, I want to make it dynamic so that the user can pick which records they want displayed (only open or only closed).   The code currently loops to display all records which are both open and closed records.

Is it possible to have a drop down menu for the user to select open or closed records? I hope I make sense.

...thanks for your reply =)
0
 

Author Comment

by:butter_fly
ID: 13971739
I figured out a work around, but I'd like to give you the points Bob cuz you are the only person that answered. =)

Have a wonderful Day
Butterfly
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 13974665
Thanks butter_fly. I think maybe I could have explained better.
In the select statement......
sqlstmt = "SELECT ID,Name,Number,Product from Users where yourOpen\Closed field = "" & dropDown.value & "'"
     The dropDown.value is a variable that can be dynamically filled. Your dropdown list from which the user makes a selection, will have a value that you can put into this variable before executing the sql statement.
Does that help clarify any?
Bob
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question