<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Документ без названия</title>
<script type="text/javascript">
function check_digits(if_no_points) {
var key = event.keyCode;
if (!(key >= 48 && key <= 57) && key != 8 && key != 46) { event.returnValue = false; }
}
function calculate() {
var price = 0;
var room_length = document.calc.room_length.value;
var room_width = document.calc.room_width.value;
var tubes_quantity = document.calc.tubes_quantity.value;
var lightpoints_quantity = document.calc.lightpoints_quantity.value;
var angles_quantity = document.calc.angles_quantity.value;
if (room_length > 0 && room_width > 0) {
document.getElementById('roof_size').innerText = room_length * room_width;
document.getElementById('roof_perimeter').innerText = 2 * room_length + 2 * room_width;
if (angles_quantity >= 4)
price = room_length * room_width * 450 + (2 * room_length + 2 * room_width) * 50 + tubes_quantity * 300 + lightpoints_quantity * 200 + (angles_quantity - 4) * 100;
}
else
document.getElementById('roof_size').innerText = "0";
document.getElementById('price').innerText = price + "руб.";
return true;
}
</script>
</head>
<body>
<form name="calc">
<table>
<tr>
<td>Кол-во точек освещения:</td>
<td><input size="10" name="lightpoints_quantity" onkeypress="check_digits()" onkeyup="calculate();" value="" /></td>
</tr>
<tr>
<td>Кол-во углов в комнате:</td>
<td><input size="10" name="angles_quantity" onkeypress="check_digits()" onkeyup="calculate();" value="4" /></td>
</tr>
<td>Стоимость потолка под ключ:</td>
<td><span id="price"></span></td>
</tr>
</table>
</form>
</body>
</html>