I often encounter this situation when I as an ASP program:
Column data in the database (such as all employee names) is listed in the list box, and the program requirements select one or more of the submitted to the next page.
But trouble is that if data (such as employees) will bring trouble to customers - to be positioned from a long list. The best solution is that the user performs data positioning in the way before choosing a fuzzy query, accurately identify the employee name, then select, and submit it.
The problem appears in front of our programmer: How to filter data from the database without refreshing the page filtering from the database. There are two kinds of methods:
1. Methods with dual list boxes
2, use
XML method
This article mainly introduces the second method:
XML solution
Programming ideas:
First, the data that needs to be placed in the list box is downloaded from the database to
XML data island;
Use JavaScript to compare each of the query conditions with each item in the data island, in the list box that meets the requirements;
This enables the content that does not refresh the new page filtering the database.
Its disadvantage is not real-time.
achieve:
The following is an example of SQL Server, and the employee name of the Employees table in the Northwind library will be filtered.
Root.childNodes (i) .GetaTribute ("emid"); // Get employee id for (j = 0; j } // Write the eligible employee information into select if (EmployeeiD! = "" && employeelastname! = ") {Option1 = Document.createElement (Option1.Value = Employeeid; option1.text = EmployeelastName WINDOW.EMPLOEELIST.ADD (option1); Employeeid = ""; employeelastname = "";}}} script>
Please enter query conditions: td> tr> Query Result: