1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">$(function(){
//Auto calc price
$('#quantity_wanted').keyup(function(){
//Recalc the price
var discountVal = 0;
var finalValue = null;
var input = parseInt($('#quantity_wanted').val());
//parseInt($('#product_price').text());
$(quantityDiscounts).each(function(key, val){
var tmpQuantity = parseInt(val.quantity);
var tmpNextQuantity = parseInt(val.nextQuantity);
if(val.id_discount_type == 2)
{
if((input >= tmpQuantity && input < tmpNextQuantity)
|| (input >= tmpQuantity && tmpNextQuantity == -1))
{
discountVal = parseFloat(val.value);
}
}
});
finalValue = sprintf('%0.2f', input * (productPrice - discountVal));
if(finalValue > 0)
{
$('#product_price_container').show();
$('#product_price').text(finalValue+' ');
}
else
{
$('#product_price_container').hide();
}
});
$('#quantity_wanted').trigger('keyup');
});
</script>
<style type="text/css">
#product_price_container {
position:absolute;
width:200px;
height:115px;
z-index:1;
}
</style>
</head>
<body><table height="53">
<thead>
<td> Quantité </td>
</thead>
<tbody>
<tr>
<td><input type="text" size="3" class="nombre" id="nombre1" value="0" onchange="javascript:calcul_prix();" /></td>
</tr>
</tbody>
</table>
<div id="product_price_container"><SPAN ID="product_price"> </SPAN> </div>
<p> </p>
<p> </p>
</body>
</html> |