Queste sono le cose che preferisco...
Credo che così sia corretto:
codice:
<html>
<head>
<script type="text/javascript">
function calcolo() {
//acquisizione estremi [a,b] e numero intervalli n
var b = parseFloat(document.getElementById('estremB').value, 10);
var a = parseFloat(document.getElementById('estremA').value, 10);
var n = parseFloat(document.getElementById('intervN').value, 10);
var h = (b-a)/n;
alert(b+' '+a+' '+n+' '+h); /* alert per debug */
var integ=0;
for (x=a; x<b; x=x+h)
integ=integ+(h*Math.sin(x));
alert(integ);
}
</script>
</head>
<body>
<form>
b= <input type="text" id="estremB" size="10">
a= <input type="text" id="estremA" size="10">
n= <input type="text" id="intervN" size="10">
<input type="button" name="calcola" value="CALCOLA" onClick="calcolo();">
</form>
</body>
</html>