Click here to Skip to main content
14,920,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi frnds,

in below code if i select fresh milk in another field it should display its price of it automatically plz help

HTML
<html>
<head>
<title>My Page</title>
</head>
<body>
<form name="myform" action="" method="POST">
<div align="center">
<select name="mydropdown">
<option value="Milk">Fresh Milk</option>
<option value="Cheese">Old Cheese</option>
<option value="Bread">Hot Bread</option>
</select>
</div>
</form>
</body>
</html>
Posted
Updated 27-Nov-13 19:55pm
v2
Comments
Jain Nishant 28-Nov-13 1:37am
   
Hi..plz let me know from where you would like to fetch the prices??
Arun-23 28-Nov-13 1:47am
   
Mysql db phpmyadmin

Use AJAX calls in the select event of the dropdown list in JQuery. And at the same time display the price fetched by that AJAX calls.
   
Its very simple - you can just use a ajax call and write it on change like this


XML
<select class="selectbox" name="mydropdown">
<option value="Milk">Fresh Milk</option>
<option value="Cheese">Old Cheese</option>
<option value="Bread">Hot Bread</option>
</select>


<script>
$(document).ready(function(){
    $(".selectbox").change(function(){
    var itemId = $(this).val();
    $.post( "ajax/getprice.php",{id : itemId }, function( data ) {
      $( "#anotherfieldId" ).val( data );
});
});
});
</script>


You can write your query to process and get the value in "ajax/getprice.php"
"data" is what you get in return
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900