load different list of values(from a database) to listbox when changing another listbox value
for ex:
First list box : -select grade-
Second List box : -select Subject-
Please Help
Thank You
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The basic idea is to submit that data to the server (either by POST back, or AJAX), and then respond with the data.
What I’ve done there is added a
javascriptfunction to be called every time the drop down value has changed.This is a skeleton of the function I’d write for the select onChange event. I’ve skipped a step or two here and used jQuery to help create an AJAX request back to the server. I will be calling my php script
processData.phpto help process which element was selected. The{}contain the data I want to send to the server, in this case the selected value. And Finally what to do once I get data back from the server.Now I’d be in my php file and able to process the data I took in and run my query to get the new data. Once done I simply
json_encodethe data and respond with it.Now back in the javascript world my
UpdateDatafunction is automatically called and passed the json data.That would allow me to generate a new select list from the returned data (assuming a key/value paired array in json).
I haven’t actually tested any code and it’s designed to be more of a guide and pseudo-code.