Is it compulsory that all dynamic dropdown menus must be called from the database? I want to include one for my latest project, although I dont know how to do it, but after searching from Google, I found that almost everyone was talking about MySQL. I was thinking <select name=""> would be enough.
Is it compulsory that all dynamic dropdown menus must be called from the database?
Share
A database is definitely useful, but not strictly required.
I have a jQuery javascript I often use for dynamic drop-downs. It updates the drop-downs from a javascript variable (json object). Most often I generate this from a database, but it could be hard coded if the site doesn’t use a database.
Edit (adding explaination)
I’ve updated the sample code to be somewhat more related to your application (only knowing it relates to classes and sessions. The example has dynamic dropdowns as follows:
(A few levels of dynamic, just to cover the script capabilities)
Now the implementation. We include a script at the top of the page (+ jQuery, which the script depends on). Then we have the HTML, we only need empty select fields with names and ids. The dynamic options are handled by the javascript.
The onload is the only javascript that needs to be modified for the application. We have an array of ‘option’ objects with their id, parent_id, and display.
And the jquery onload function adds the options into the dropdown and if course changes then semester dropdown should update, and if semester dropdown then time dropdown is updated.
The scripts has one additional property in that it hides the field and it’s label if there are no related options for a given selection.
A complete html page combining these parts can be viewed here: http://snipt.org/Uul0 (Just sav to an html file to demo it)
So this shows how you can easily create dynimic dropdowns without a database and even without server side code (PHP). This is purely JQuery and HTML). Now, that said, I’m not saying you are better off without a database, just that it’s not strictly needed for dynamic dropdowns.
Sorry this is already a long essay. That’s all I have to offer here.
The included script
Sample usage
The HTML
The onload