Do I have to use JQuery to populate my second drop down menu?

At the moment, I am trying to create two drop down menus that will act as time intervals. My goal is to set it up where if the user selects a year in the first drop down menu, then the next menu will automatically populate with values that are >= the first menu selection. Here is both drop down menus that gather years by querying to my database.

[php]



Please select a year

echo " "; <?php $query = "select distinct year from table";

$result = $conn->query($query);
while($row = $result->fetch_object()) {
echo “”.$row->year."";
}
?>

Please select a year echo " "; <?php $query = "select distinct year from table";

$result = $conn->query($query);
while($row = $result->fetch_object()) {
echo “”.$row->year."";
}
?>

[/php]

Both of these drop down menus gather years from my database. Instead, I want my year2 menu to grab only the years >= the year value that the user selects in the first drop down menu. My question is how do I go about doing this? Do I still have to create three separate files, JQuery file, function file, and this file, or, is there a simpler way to go about this? Any help would be greatly appreciated.

If you are trying to do this without refreshing the page then yes you need to use javascript. It might sound like a lot but it’s actually pretty easy. I actually have a tutorial on this http://amecms.com/article/Building-Chained-Select-Boxes-with-Jquery-and-PHP

Sponsor our Newsletter | Privacy Policy | Terms of Service