Making a form where availible options change based on input
Posted: Thu Jan 22, 2004 5:26 pm
I've got a feeling this may require javascript, but countless google searches haven't turned up anything much useful.
Anyway, here's the description of what I want to do:
I want a form with various lists for people to choose from.
When the user chooses something from the first list, the second list will then be populated based on a MySQL database query.
ie. Say the first list is "category", and the second is "item". When someone chooses an area, I want the list of items to show all the items in that area.
eg. I choose the category "hardware" and the second list shows "motherboard, RAM, Hard Drive" etc.
The catch is that I have lots of items and categories (the example above I just made up to give an idea of what I'm doing), and I don't want to query the database for all items and store them in an array until the user chooses something. I think it would be more efficient (if it's possible) to query the database after the user clicks on the category they want.
Another catch is that the form must look 'the same' (apart from the values in the lists, obviously) the whole time. At the moment I have 'different' pages (all generated by the one big PHP script). One to get the category, then after that is submitted, another page displays the applicable items to choose from.
Anyone have any ideas, or perhaps pointers in the right direction of elsewhere that may be able to help?
Thanks heaps for your time...
Anyway, here's the description of what I want to do:
I want a form with various lists for people to choose from.
When the user chooses something from the first list, the second list will then be populated based on a MySQL database query.
ie. Say the first list is "category", and the second is "item". When someone chooses an area, I want the list of items to show all the items in that area.
eg. I choose the category "hardware" and the second list shows "motherboard, RAM, Hard Drive" etc.
The catch is that I have lots of items and categories (the example above I just made up to give an idea of what I'm doing), and I don't want to query the database for all items and store them in an array until the user chooses something. I think it would be more efficient (if it's possible) to query the database after the user clicks on the category they want.
Another catch is that the form must look 'the same' (apart from the values in the lists, obviously) the whole time. At the moment I have 'different' pages (all generated by the one big PHP script). One to get the category, then after that is submitted, another page displays the applicable items to choose from.
Anyone have any ideas, or perhaps pointers in the right direction of elsewhere that may be able to help?
Thanks heaps for your time...