peakbagger — 2012-07-18T14:44:29-04:00 — #1
I am attempting to populate an HTML drop down menu based on the selection from a previous drop down menu and access to MySQL Database fields. I would like to populate three drop downs in total based on the data contained in the MySQL database. I already have built and have access to my database.
guido2004 — 2012-07-19T02:02:39-04:00 — #2
Welcome to the SP forums.
You might want to take a look at AJAX. Do a google search for 'AJAX drop down' or something like that and you should fine loads of tutorials and examples.
cpradio — 2012-07-19T06:01:01-04:00 — #3
How often does this data change? Usually for data that isn't mission critical, I use a scheduled task or a cronjob to write out the information to a flat file that I can just use a <?php include('path to file'); ?> on so the HTML is already built and can be easily included into your document. Then I schedule the task or cronjob to run nightly, weekly, whatever makes sense.
starlion — 2012-07-19T06:52:45-04:00 — #4
Is it that time of year again? You might want to look at what last year's students did when they asked us to do their homework for them too. Search the forum a bit.
peakbagger — 2012-07-19T08:55:52-04:00 — #5
Thank you for the recommendation and welcoming--most of what I've found already is AJAX oriented--I'll give that a shot. The Make, Model and Year values update per annum, but I do have other variables that will update as quickly as every five minutes. Sorry, StarLion, but I wish I was still in school. I'm a few years beyond that now and am just getting into server-side scripting.
cups — 2012-07-19T13:43:27-04:00 — #6
If you are going to attempt a server-side only solution, you probably only need 2 webpages.
1 Pick year and make. ("2000" and "Ford")
2 Show models (available matching models)
.... then possibly link on to another page showing just that model?
I think we'd need to know what fields you have in each table, I'm especially interested to hear what you have in your "year" table ...
mittineague — 2012-07-19T20:14:39-04:00 — #7
Hi Peakbagger, welcome to the forums,
In school or out, we could all stand to learn a few things
If I understand you correctly, you have an initial form containing "common to all" selects, that when once chosen will lead to specific "not common to all" choices.
So maybe something like this:
Initial page populates the select with the "common" values taken from the database.
Form sends input values to server.
Server finds applicable "specific" values and sends back a second form using those values.
Form sends those input values to the server.
Server sends back the final page.
You may be interested in using the QuickForm2 package as it would save you from a lot of work.
This package provides methods to create, validate and render HTML forms.
* Supports all form elements defined by HTML standard, provides several
* Server-side and client-side validation, several common rules provided
* Multipage forms (tabbed forms and wizards)
* Pluggable elements, rules, renderers and renderer plugins
Major advantages over PHP4 version:
* Most of the package's functionality is covered by unit tests
* DOM-like API for building the form structure, new streamlined API for
elements' values handling
* Default rendering without tables (inspired by
* Renderer plugins for elements with complex rendering needs
* Ability to chain validation rules with 'and' and 'or'
* Client-side validation can run "live" on changing the form fields,
validation errors are displayed near the fields instead of in alert()