I have an html+php page. There are 3 drop down menus. Values for the menus come from an sqlite database. I'd like to make a selection from the first menu, and based on that choice, have the second drop down menu dynamically populated. And then again the same for the 3rd menu.
I have seen Dynamically populate drop down menu with selection from previous drop down menu but: 1. I would like to have this done with php alone, if possible 2. Without any need for external plugins/resources, because the page will run on the intranet without access to the web.
I have tried the following code, with post/get methods, but when the 2nd post is called it clears the data from the 1st post.
<form action="" method="get" name="proj_form">
<?php
$db = new SQLite3('FEINT_DB.db');
$sql="SELECT project FROM synthesis_metrics WHERE is_project=1";
$query = $db->query($sql); // Run your query
echo '<select name="project" id="project">';
while ($row = $query->fetchArray()) {
echo '<option value="'.$row['project'].'">'.$row['project'].'</option>';
}
echo "</select>";
$project =$_GET['project'];
?>
<input type="submit" name="projbutton" value="Submit"/></form>
<?php echo "You chose $project <br>"; ?>
<form action="" method="post">
<?php
$sql="SELECT CL FROM synthesis_metrics WHERE is_CL=1";
$query = $db->query($sql); // Run your query
echo '<select name="CL" id="CL">';
while ($row = $query->fetchArray()) {
echo '<option value="'.$row[CL].'">'.$row['CL'].'</option>';
}
echo "</select>";
$CL =$_POST['CL'];
?>
<input type="submit" name="button" value="Submit"/></form>
<?php echo "You chose $CL <br>"; ?>
<form action="" method="get" name="tile_form">
<?php
$sql="SELECT tile FROM synthesis_metrics WHERE CL=$CL AND is_t=1";
$query = $db->query($sql); // Run your query
echo '<select name="tiel" id="tiel">';
while ($row = $query->fetchArray()) {
echo '<option value="'.$row[tiel].'">'.$row['tiel'].'</option>';
}
echo "</select>";