On a webpage I am trying to create a dropdown menu with some features. After a selection has been made in the dropdown menu the PHP variable "$bin_sec" gets updated to a new value. After $bin_sec has been updated I want a div element (with the id tag of "WHAT") in my webpage to now be reloaded and now take on the new value of $bin_sec.
I'm open to using AJAX, PHP, jQuery, MySQL, etc...
I can't find or come to a working solution.
My code for the dropdown menu:
<form id="container2" method="post">
<select name="name" onchange='$("#WHAT").load("testing.php",{bin_sec:x});'>
<?php $bin_sec=60;?>
<option selected="selected" <?php if ($_POST['name'] == '60'){ print 'selected'; $bin_sec=60; }?> value="60">1 Minute</option>
<option <?php if ($_POST['name'] == '120'){ print 'selected'; $bin_sec=120; }?> value="120">2 Minutes</option>
<option <?php if ($_POST['name'] == '300'){ print 'selected'; $bin_sec=300; }?> value="300">5 Minutes</option>
<option <?php if ($_POST['name'] == '600'){ print 'selected'; $bin_sec=600; }?> value="600">10 Minutes</option>
</select>
</form>
<div id="WHAT">
<?php
echo $bin_sec;
...
?>
</div>
testing.php:
<?php
$bin_sec = $_POST['name'];
?>
<script type="text/javascript">
$("#WHAT").load("index.php #WHAT")
</script>
I think this code should work but it doesn't... Any corrections would be very much appreciated. Thank you in advance.
if(isset($_POST['name']) && $_POST['name'] == 'X') { .. }<option <?php if ($_POST['name'] == '120'){ print 'selected'; $bin_sec=120; }?> value="120">2 Minutes</option>--to become--<option <?php if(isset($_POST['name']) && $_POST['name'] == '120'){ print 'selected'; $bin_sec=120; }?> value="120">2 Minutes</option>--is this what you had mind?