var i,j; i = 0, j = 0; for (i = 1; i <= 9; i++) { for (j = 1; j <= i; j++) { document.write(j + "*" + i + "=" + i * j + "  "); } document.write("<br/>"); } var a, b, c; function sum(a, b, c) { var s = ((parseInt(a.value) + parseInt(b.value)) * (parseInt(c.value))) / 2; alert("梯形的面积是:" + s); } </script> <form> 上底<input type="text" name="a"><br /> 下底<input type="text" name="b"><br /> 高度<input type="text" name="c"><br /> <input type="button" onclick="sum(a,b,c)" value="求面积">