1

ユーザーから値を受け取り、それらの値を同じファイル内の 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>
4

3 に答える 3

2

タイプミスがあります。であってはなりgetElementByIdませんgetElementByID

以下のように値をコンソールに出力できます。

console.log(document.getElementById("cf").value);

于 2013-08-02T16:39:18.320 に答える