exzibit,
можно так чуток сократить
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<form onsubmit="return false;" oninput="getResult()">
<select size=1 id=product onChange="getResult()">
<option value=1 selected>Песок мытый</option>
<option value=2>Отсев песка</option>
<option value=3>Гравий 20x40</option>
<option value=4>Щебень 5х20</option>
<option value=5>Щебень 20х40</option>
<option value=6>Щебень 40х70</option>
<option value=7>Отсев щебня</option>
</select>кол-во:
<!--[if IE]> <input id="count" type="number" value=1 min=0 onpropertychange="getResult()"> <![endif]-->
<!--[if !IE]><!--> <input id="count" type="number" value=1 min=0 onChange="getResult()"> <!--<![endif]-->
<select size=1 id="measure" onChange="getResult()">
<option value=1 selected>м3</option>
<option value=2>кг</option>
</select>
Цена: <span id="result">350 руб. (1300 кг.)</span>
</form>
<script>
function getResult(){
var table= {
1:{price:350,density:1630},
2:{price:150,density:1580},
3:{price:700,density:1620},
4:{price:1100,density:1360},
5:{price:1100,density:1360},
6:{price:1100,density:1400},
7:{price:300,density:1580}
};
var price=0,value=0,
elems = document.querySelectorAll('#product, #count, #measure, #result');
elems = [table[elems[0].value], elems[1].value, elems[2].value, elems[3]];
if (elems[2]==1) {
price=((elems[0].price*elems[1]).toFixed(2));
value=((elems[0].density*elems[1]).toFixed(0));
price+=' руб. ('+value+' кг.)'
}
else if (elems[2]==2) {
price=((elems[1]/elems[0].density*elems[0].price).toFixed(2));
value=((elems[1]/elems[0].density).toFixed(1));
price+=' руб. ('+value+' м3.) '
}
elems[3].innerHTML=price
}
</script>
</body>
</html>