-
prepopulate a drop down list from sql database
I have a form with a drop down list. Some of this form has been prepopulated with data from a mysql database. Everything else is working except I don't know how to prepopulate the drop down list.
I hope I explained this right.
Example:
Drop down list options: 1, 2, 3, 4, 5
data from mysql: 3
So when the user gets to the drop down list, he sees 3 selected and he can then change it
Thanks for any help
Last edited by mcolton; 01-09-2010 at 07:00 PM.
-
-
Looks like this was solved. For anyone else with a similar question, here are the basic steps:
1. Use PHP or another server side language to gather the relevant information from the database.
2. Use that language to then output the TEXT of the javascript for the dropdown menu, such as:
echo 'mymenu[] = "item1";';
(repeat for each item).
3. Then Javascript will have the information when the page loads.
(Remember: there is no easy way to get the data using Javascript, so "prepopulating" it is the best approach.)
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks