I need a solution for a combo box that will display a list of choices. When a user selects an option, I want JavaScript to execute a MySql query based on the selection and return a simple value to be shown on the page next to the combo box.
The query will be a basic
SELECT foo FROM tblexample WHERE id = blah
(where blah represents the combo box value). The result will be a straightforward number. If the user picks a different option, the query should automatically run again and update the displayed value.
I am considering loading the entire table into an array upon page load. While I primarily work in PHP, I am not proficient in JavaScript. I am looking for a sample code snippet that I can study and adapt as needed.
Instead of having a submit button in a form that users need to click every time they change the combo box selection, I prefer a seamless and quick display for a better user experience.