I’m creating an eCommerce website, I’m trying to add option, where the buyer select a item size through a drop-down list, then it pass variables to jquery then jquery pass it to php, and if the item size is available in stock it’s display an Add to cart button, otherwise a out of stock button. I manage to get it working till the point where it passes the item size to php, But I don’t know how to pass the product id, which is needed to check the database.
the size select:
<form id="form1" name="form1" method="post" action="cart.php">
<label>Size:</label>
<select name="search" class="search" id="searchbox">
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
<option value="3XL">3XL</option>
<option value="4XL">4XL</option>
<option value="5XL">5XL</option>
</select>
<input type="hidden" name="product_id" id="product_id" value="'.$pid.'" />
</form>
<div id="display">
</div>
my query code:
<script type="text/javascript">
$(document).ready(function(){
$(".search").change(function()
{
var searchbox = $(this).val();
var dataString = 'searchword='+ searchbox;
if(searchbox=='')
{}
else
{
$.ajax({
type: "POST",
url: "check_stock.php",
data: dataString,
cache: false,
success: function(html)
{
$("#display").html(html).show();
}
});
}return false;
});
});
</script>
Any help appreciated
example of what I got so far
http://mysandbow.webatu.com/view_product?product=2
you get the ID using this line of code