I have been looking for this for so many days, but still could not understand.
I want to create a drop-down menu for the search and the stream will be like this:
1st Dropdown
Search by:
Category
Mark
Location
The supplier
Owner
And as soon as the user clicks on one of the above, the second DropDown should display the corresponding list in accordance with the 1st DropDown:
For example, 1st DropDown = Category:
2nd Dropdown
Limit:
Laptop
Desktop
router
LCD
Scanner
Or 1st DropDown = Brand:
2nd Dropdown
Limit:
Dell
Sony
HP
Samsung
Acer
And the third DropDown menu will be Order By 1 DropDown, for example:
3rd dropdown
Sort by:
Category
Mark
Location
The supplier
Owner
My problem is that each parameter in the 1st DropDown has its own table, and this will bring up the second DropDown menu, and for some reason I cannot figure out what to call it. All the tutorials and examples I found run something in the first DropDown menu, which is within 1 table, and the 2nd and 3rd DropDown can call up another table. (For example: Country, State, City).
Therefore, I want to know if this is possible when the first DropDown menu is from different tables, the second DropDown menu will be populated from the first DropDown menu option, and the 3rd DropDown menu will order the second DropDown menu with the 1st DropDown menu item.
I hope you understand what I ask, and I really hope to receive feedback very soon, this is so necessary. Thanks, and I really appreciate it!
EDITED
search.html
..... <form id="drop_list" name="drop_list" action="searchedasset.php" method="post" > <fieldset><table><tr> <thead> <tr><legend><b>SEARCH ASSET</b></legend></tr> </thead> <tbody> <tr> <td>Search By :</td> <td><select name="cat_id" onChange="SelectSubCat1();" > <Option value="">Choose Search By</option> </SELECT> </td> </tr> <tr> <td>Limit By :</td> <td><select id="SubCat1" name="SubCat1"> <Option value="">Choose Limit By</option> </SELECT> </td> </tr> <tr> <td>Order By :</td> <td><select name="SubCat2"> <option value="">Choose Order By</option> <option value="1">Brand </option> <option value="2">Category </option> <option value="3">Project </option> </select> </td> </tr> </tbody> </tr></table></fieldset> .....
search.js
function fillSearch(){ // this function is used to fill the category list on load addOption(document.drop_list.cat_id, "1", "Brand", ""); addOption(document.drop_list.cat_id, "2", "Category", ""); addOption(document.drop_list.cat_id, "3", "Project", ""); } function SelectSubCat1(){ // ON selection of category this function will work removeAllOptions(document.drop_list.SubCat1); //clear all the elements of the second list addOption(document.drop_list.SubCat1, "", "Choose Limit By", ""); if(document.drop_list.cat_id.value == '1'){ addOption(document.drop_list.SubCat1,"1", "DELL"); addOption(document.drop_list.SubCat1,"2", "ACER"); addOption(document.drop_list.SubCat1,"3", "SONY"); addOption(document.drop_list.SubCat1,"4", "SAMSUNG"); addOption(document.drop_list.SubCat1,"5", "APPLE"); } if(document.drop_list.cat_id.value == '2'){ addOption(document.drop_list.SubCat1,"='1'", "Notebook"); addOption(document.drop_list.SubCat1,"2", "Desktop"); addOption(document.drop_list.SubCat1,"3", "LCD Projector"); addOption(document.drop_list.SubCat1,"4", "Scanner"); addOption(document.drop_list.SubCat1,"5", "Printer"); } if(document.drop_list.cat_id.value == '3'){ addOption(document.drop_list.SubCat1,"1", "1st Purchase"); addOption(document.drop_list.SubCat1,"2", "2nd Purchase"); addOption(document.drop_list.SubCat1,"3", "3rd Purchase"); addOption(document.drop_list.SubCat1,"4", "4th Purchase"); addOption(document.drop_list.SubCat1,"5", "5th Purchase"); } } } .....
Note that SubCat1 was supposedly from three different tables that have a different name:
eg. [cat_id.value == '1', SubCat1 == 'brandid'] [cat_id.value == '2', SubCat1 == 'categoryid'] [cat_id.value == '3', SubCat1 == 'purchaseid' ]
So can we do this? Change SubCat1 according to their name in the database? This displays the data on the next page. Thanks.