所以我正在尝试创建一个将摄氏温度转换为华氏温度的脚本。当我运行它时,我在第 1 行遇到错误。请帮帮我......我不需要新代码,我只需要修复这个:/
window.addEventListener("load", init, false);
function init() {
var celcius = document.getElementById("celcius");
var fahrenheit = document.getElementById("fahrenheit");
var button = document.getElementById("button");
celcius.value = "";
fahrenheit.value = "";
button.addEventListener("click", controle, false);
}
function controle() {
var celcius = document.getElementsById("celcius");
var fahrenheit = document.getElementsById("fahrenheit");
if ((celcius.value != "") && fahrenheit.value != "") {
document.getElementsById("note").innherHTML = "Please only enter information in one field."
} else {
calculate();
}
}
function calculate() {
var celcius = document.getElementsById("celcius");
var fahrenheit = document.getElementsById("fahrenheit");
if (celcius.value != "") {
fahrenheit.value = (parseFloat(celcius.value) * 1.8) + 32;
} else {
celcius.value = (parseFloat(fahrenheit.value) - 32) / 1.8;
}
document.getElementsById("note").innerHTML = "Het omrekenen is damn voltooid.";
}