<script type="text/javascript">
var productpr, qty;
function price() {
var productpr = document.getElementsByName('productpr')[0],
info = productpr.options[productpr.selectedIndex].value;
return parseInt( info.split(':')[1], 10 );
}
function quantity() {
return parseInt(qty.value, 10);
}
function update_subtotal(event) {
var subtotal = document.getElementById('subtotal').getElementsByTagName('b')[0];
subtotal.textContent = '$' + ( price() * quantity() ).toFixed(2);
}
window.addEventListener('load', function (event) {
productpr = document.getElementsByName('productpr')[0];
qty = document.getElementsByName('qty')[0];
productpr.addEventListener('change', update_subtotal, false);
qty.addEventListener('keyup', update_subtotal, false);
update_subtotal(); // just in-case if they refreshed the page and kept the values
}, false);
</script>