Hello,
Is it possible to use a javaScript value in php code? I have 3 drop down menus.
Drop down 1 is dynamic and pulls three values from a table. Base on which selection is made in drop down 1, drop down 2 loads the options from another table using the following code:
I want my third drop down to load its options from another table based on the selection of drop down 2. However, as I'm very new to JS and see that a function called json_encode is actually filling in the options, I will need the value of the selection passed to the db read in order to get the options for the third drop down.
Is this even possible or do I need to remake my forms to limit only two dynamic drop downs?
Thanks for any insights.
Chris
Is it possible to use a javaScript value in php code? I have 3 drop down menus.
Drop down 1 is dynamic and pulls three values from a table. Base on which selection is made in drop down 1, drop down 2 loads the options from another table using the following code:
<?php
$siteoptions = array();
if ( !$form->data['sites'] || count($form->data['sites']) < 1 ) {
// no result was found
$siteoptions[] = 'Please select a site';
} else {
foreach ($form->data['sites'] as $d ) {
$siteoptions[$d['site_id']] = $d['site'];
}
}
echo json_encode($siteoptions);
?>
I want my third drop down to load its options from another table based on the selection of drop down 2. However, as I'm very new to JS and see that a function called json_encode is actually filling in the options, I will need the value of the selection passed to the db read in order to get the options for the third drop down.
Is this even possible or do I need to remake my forms to limit only two dynamic drop downs?
Thanks for any insights.
Chris