Please, i need help for create a simple form which takes into account a price and a quantity. There is also an initial value. Thank you.
HTML:
<input type="number" min="0" max="5" value="1" onclick="total(this.form);"/>
<input type='checkbox' value='10' />10
<div id='total'></div>
JAVASCRIPT:
var init_price = 200;
$('#total').html(init_price);
var tot = 0;
$('input:checkbox').change(function(){
if($(this).is(':checked')){
tot = Number($('#total').html()) + Number($(this).val());
} else {
tot = Number($('#total').html()) - Number($(this).val());
}
$('#total').html(tot);
});
Aucun commentaire:
Enregistrer un commentaire