codice:
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!--
function updateSum( __hForm, __productEl, __quantityEl, __priceEl )
{
var _hProduct = __hForm.elements[__productEl];
var _hQuantity = __hForm.elements[__quantityEl];
var _hPrice = __hForm.elements[__priceEl];
if ( _hProduct.selectedIndex == -1 )
_hPrice.value = "0 Euro";
else {
_hPrice.value = parseFloat( _hProduct.options[_hProduct.selectedIndex].value ) *
parseInt( _hQuantity.value ) + " Euro";
}
}
//-->
</script>
</head>
<body>
<form>
Prodotto:
<select name="product" onchange="updateSum( this.form, 'product', 'quantity', 'price');">
<option value="1">Penna (1 euro/pezzo)</option>
<option value="2">Matita (2 euro/pezzo)</option>
<option value="100">Scarpe (100 euro/pezzo)</option>
<option value="700">Giubotto in pelle firmato (700 euro/pezzo)</option>
</select>
Quantità:
<input type="text" name="quantity" value="0" onchange="updateSum( this.form, 'product', 'quantity', 'price');" />
Prezzo totale:
<input type="text" name="price" value="0" />
</form>
</body>
</html>