I have dropdown-menu-1 with medicine names from my database. what I need to happen is when I select a specific medicine from dropdown-menu-1, Dropdown-menu-2 automatically shows the quantity of that medicine from the database.
I think my problem is how to do the query inside the javascript.
Database:
medicine A with a quantity of 5
medicine B with a quantity of 7
medicine C with a quantity of 10
if you click medicine a, the option in dropdown-menu-2 should be from 1 to 5, if medicine b, the option in dropdown-menu-2 should be from 1 to 7 and medicine c should be from 1 to 10.
--> Dropdown-menu-1
--> Dropdown-menu-1 | Dropdown-menu-2
Here's my code:
<select id="one">
<?php
while ($print = mysql_fetch_array($query3)){
echo "<option value\"".$print['generic_name']." ".$print['brand_name']."\">".$print['generic_name']." ".$print['brand_name']."</option>"; }
?>
</select>
<select id="two"></select>
<script type="text/javascript">
$(function () {
$("#one").change(function (e) {
$("#two").empty();
<?php $query4 = mysql_query("SELECT * FROM medicine, status WHERE medicine.med_id=status.med_id AND medicine.generic_name=")?>
var options =
$("#one option").filter(function(e){
return $(this).attr("value") > $("#one option:selected").val();
}).clone();
$("#two").append(options);
});
});
</script>
-HTML RENDER-
I was ready to post a picture of the html render in my post, I didn't know I needed 10 rep points to add an image to my post. I posted it on photobucket instead http://s1132.photobucket.com/user/klleww/media/post.png.html