here is jQuery based script with some animation and total cost count:
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#total{color:Green;background-color:transparent;font-weight:bold;}
#gearbox{text-align:center;padding:20px 20px;}
#gearbox input{background-color:transparent;color:Crimson;font-weight:bold;margin-left:10px;margin-right:10px;border:none;cursor:pointer;}
input{cursor:pointer;}
.pricetext{display:none;}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
function countTotal(){
var tot=0;
$('#orderpizza').find(':checked').each(function(){var tt=$(this).next().next().text(),p_curr=parseFloat(tt.substring(1,tt.length));tot+=p_curr;});
res=tot.toString();
if(res.indexOf('.')==-1){res+='.00';}
else{var tail=res.substring(res.indexOf('.'),res.length);if(tail.length==2){res+='0';}}
$('#total').html(res);
}
$(document).ready(function(){
$('#reset').click(function(){$('#orderpizza').find('.pricetext').css('display','none').css('margin-left','0px');setTimeout("countTotal()",100);});
$('#Size input').each(function(){
$(this).click(function(){
if($(this).next().next().css('display')=='none'){
$(this).parent().parent().find('.pricetext').css('display','none').css('margin-left','0px');
$(this).next().next().fadeIn('fast',function(){
$(this).animate({marginLeft:'10px'},'fast',function(){countTotal();});
});
}
});
});
$('#filling input').each(function(){
$(this).click(function(){
if($(this).is(':checked')){$(this).next().next().fadeIn('fast',function(){$(this).animate({marginLeft:'10px'},'fast',function(){countTotal();});});}
else{$(this).next().next().animate({marginLeft:'0px'},'fast',function(){$(this).fadeOut('fast',function(){countTotal();});});}
});
});
});
</script>
</head>
<body>
<p>Select the size, base and toppings for you pizza.</p>
<form id="orderpizza" action="" onsubmit="return false;">
<p>Total cost: £<span id="total">0.00</span></p>
<fieldset id="Size"><legend class="formheading">Select the size of pizza</legend>
<p><input type="radio" name="selectedpizza" value="size10" /><span>10" pizza base </span><span class="pricetext" id="pizzasize1">£4.50</span></p>
<p><input type="radio" name="selectedpizza" value="size12" /><span>12" pizza base </span><span class="pricetext" id="pizzasize2">£6.00</span></p>
<p><input type="radio" name="selectedpizza" value="size15" /><span>15" pizza base </span><span class="pricetext" id="pizzasize3">£7.50</span></p>
</fieldset>
<fieldset id="filling"> <legend class="formheading">Select fillings</legend>
<br />
<input type="checkbox" name="filling" value="mushrooms" /><span>Mushrooms </span><span class="pricetext" id="filling1">£0.50</span><br>
<input type="checkbox" name="filling" value="ham" /><span>Ham </span><span class="pricetext" id="filling2">£0.50</span><br />
<input type="checkbox" name="filling" value="peppers" /><span>Peppers </span><span class="pricetext" id="filling3">£0.50</span><br />
<input type="checkbox" name="filling" value="pepperoni" /><span>Pepperoni </span><span class="pricetext" id="filling4">£0.50</span><br />
<input type="checkbox" name="filling" value="bbq" /><span>BBQ Chicken </span><span class="pricetext" id="filling5">£0.50</span><br />
<input type="checkbox" name="filling" value="meatballs" /><span>Meatballs </span><span class="pricetext" id="filling6">£0.50</span><br />
<br />
</fieldset>
<div id="gearbox"><input id="reset" type="reset" value="Reset" /><input type="submit" value="Submit" /></div>
</form>
</body>
</html>
working example pizza
hope it will be useful
Bookmarks