3

ボタンをクリックしてもボタンが機能しない特定の理由はありますか? これがコードです。

    <script>
    function save() {
        if (isNaN(document.form.result.value) || document.form.result.value == 0) {
        document.getElementById('hours').innerHTML = "There was an input error, make sure that: <br> The calculator field is not empty <br> Only include numbers as an input";
        document.getElementById('hoursdiv').style.background = "yellow";
        } else {
        savedvalue = document.form.result.value;
        document.getElementById('hours').innerHTML = "Hours Worked This Week: " + savedvalue;
        document.getElementById('hoursdiv').style.background = "";
            }
    }
    function clear() {
        alert("hi");
    }
   </script>

    <div>
    <!-- Save Button -->
<input class = "customSubmitButton" type="button" onClick="save();" value="Save">

   <!-- Clear Button -->
<input class = "customSubmitButton" type="button" onClick = "clear()" value = "Clear">

    <div id = "hoursdiv">
        <p>
           <strong id = "hours"> </strong>
        </p>
    </div>
</div>

[保存] ボタンは正常に機能します。

4

1 に答える 1