- This topic is empty.
-
AuthorPosts
-
October 10, 2012 at 11:17 am #40232
gilgimech
ParticipantOK,
I know how to dynamically populate a dropdown from database entries, and I know how to use JavaScript/jQuery/Ajax to populate a dropdown from a selected item in another dropdown.What I’m have trouble with it how do you populate a dropdown based on a dynamically populated dropdown.
For example. I have a this code
$flight_sql = "SELECT * FROM wp_flr_flights";
$flight_result = mysql_query($flight_sql);
echo '';
?>
This populates a dropdown from entries from my database, so If a user selects the first option with the $loc_id value as (ID) 1. How do I populate the next dropdown only with rows from my table that have an (ID) 1.
I'm thinking it has something to do with $_GET, but I'm not a backend developer and I'm not sure how to go about this
Thanks in advanced.
October 10, 2012 at 4:28 pm #111612mweldan
Memberhow is table structure looks like?
it should has column for parent menu id. from there you can check for each menu if it has parent menu or not.
October 11, 2012 at 10:42 am #111648gilgimech
ParticipantI’m not sure what you mean by parent menu ID. This is actually for a form not a menu. For some reason it doesn’t show all my code.
It should look like this.
$flight_sql = “SELECT * FROM wp_flr_flights”;
$flight_result = mysql_query($flight_sql);
echo ‘‘;
?>But every row has a loc_id ID which is what I want to use to populate other section of the form if it is selected.
October 12, 2012 at 8:52 am #111731mweldan
Membersorry. was too sleepy on my previous comment.
you can do this both from server and client side
here is my example of how you can do it with php. form required to be submitted to process it.
https://gist.github.com/3879053
if you’re on wordpress form action should be frontpage if form is used on frontend.
if form is on options or admin page . form action should be page script name respectively. for example: admin.php?action=blablabla for get request.
you can also do this on client side with javascript. print next dropdown selection values based on first dropdown selection. triggered on select or click.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.