我正在尝试制作一个接受用户值的表单,然后将这些值传递给同一文件中的 JS 函数进行一些计算。我现在只是想将值打印到控制台,但我不断收到错误消息"Object #<HTMLDocument> has no method 'getElementByID'"
。这是代码:
<!DOCTYPE html>
<html>
<body>
<form action="javascript:formHandler();" method="get">
<h1 align="center">Set the parameters you would like to visualize</h1>
Center Frequency: <input type="text" name="cf" id="cf"><br>
Bandwidth: <input type="text" name="bw" id="bw"><br>
Number of Bins: <input type="text" name="bins" id="bins"><br>
Number of Values to be Visualized: <input type="text" name="values" id="values"><br>
<input type="submit" value="Submit">
</form>
<script>
function formHandler()
{
console.log(document.getElementByID("cf")); // This is where I'm getting the error
}
</script>
</body>
</html>