【发布时间】:2017-09-12 23:40:22
【问题描述】:
所以...我的作业说...
创建一个名为calcBMI() 的函数,该函数使用体重和身高文本框中的值执行计算,并将结果分配给BMI 文本框。
使用 parseInt() 函数将该值转换为整数。
通过使用 documentobject.getElementByID(name) 和每个文本框的 value 属性从函数中引用文本框(换句话说,不要使用函数参数 AKA 将值传递给函数)。
添加事件监听器以调用 calcBMI() 函数
我在这里做过。请记住,在 html 中引用了 javascript 文件。每当我按下计算按钮时,什么都没有发生。
function calcBMI() {
var weight = parseInt(documentobject.getElementByID("weight"));
var height = parseInt(documentobject.getElementByID("height"));
var result = (weight * 703) / (height * height);
var textbox = documentobject.getElementById('Result');
textbox.value = result;
}
document.getElementById("submit").
addEventListener("click", calcBMI(), false);
【问题讨论】:
-
什么是html?是否抛出任何错误?
标签: javascript