今天刚开始学习Javascript,我被困住了。当我提交时,页面会重新加载。我是否将 .value 放在错误的位置?也许其他一些菜鸟错误?
<script type="text/javascript">
function Calculate() {
var volume = document.getElementById('volume').value;
var carbonation = document.getElementById('carbonation').value;
var temperature = document.getElementById('temperature').value;
var sucrose = (15.195 * volume * (carbonation - 3.0378 + (0.050062 * temperature) - (0.00026555 * (temperature * temperature))))/28.4;
var dextrose = sucrose + (sucrose * 0.15);
document.write('<div id="result">You need ' + math.round(dextrose * 100)/100 + ' ounces of dextrose</div>');}
</script>
<form>
<input id="volume" type="text">
<input id="carbonation" type="text">
<input id="temperature" type="text">
<input type="submit" onclick="Calculate();" value="Calculate">
</form>