I am working on a library type database. Supposed I want to create 2 input fields (using PHP) each having its own autosuggest capability in order to help filter user's selection. However, the values to be populated in field #2 will be dependent upon the value searched and selected by the user in field #1. I wonder if I should even make the 2nd field inactive until a valid value (that exists in the database) is properly searched and selected in field #1.
Field 1: Autosuggesting searches for a list of libraries.
Field 2: Upon entering a proper library in field 1, field 2 would be able to autosuggest books that are contained within that library.
I want to accomplished this 2-step autosuggest all in one page, as opposed to moving the user to a whole another page in order to search the books within the selected library.
I am working with a lot of libraries, so a drop down list doesn't make much sense for field #1.
I have a "books_library" table in my database that each has a bookID as well as a library ID showing that it belongs to that particular library. I can easily populate field #2 autosuggest with all the books, the problem is, how do I filter the autosuggest in field #2 based on the library ID generated from field #1?
Does anyone know a proper name for this sort of project? I could not find anything like this in google. The closest thing is a drop-down list one after another based on values selected in a previous drown down list. But I am working with a lot more data than drop-downs can provide in a user friendly manner.
Please help!
I wonder if I should even make the 2nd field inactive until a valid value (that exists in the database) is properly searched and selected in field #1.
I would go one step further and not show it until they've done so. It sounds like you want to use the autocomplete jquery ui plugin (or an autocomplete plugin from some other library - there's more than one.)
As far as using what's been selected from the first text box for the second, bind a function to the select event of the first autocomplete that sends data to the server to prime the "source" before showing the second autocomplete.