JavaScript の独学を始めたばかりで、いくつかの基本的な演習を行っています。現在、3 つの値を取り、最大値を出力する関数を作成しようとしています。ただし、関数はボタンのクリック時に起動することを拒否します。デバッグのためだけに別の非常に単純な関数を作成しようとしましたが、それも起動を拒否しました。私は、ほとんど同じ方法で (3 つではなく 2 つのパラメーターを持っていた) 正常に動作する他の練習用関数を作成しました。どんな洞察も大歓迎です。
<!DOCTYPE HTML>
<html>
<head>
<script type = "text/javascript">
<!--
//Define a function Max() that takes three numbers as
//arguments and returns the largest of them.
function Boo(){
document.write("boo");
alert("boo");
}
function Max(p1, p2, p3){
document.write(p1+p2+p3);
alert('BOO!')
document.write(document.getElementById('value1').value);
var max = Number(p1);
v2 = Number(p2):
v3 = Number(p3);
if (v2 > max)
max = v2;
if (v3 > max)
max = v3;
document.write(max);
}
-->
</script>
</head>
<body>
<form>
<input type="text" id="value1" name="value1"/><br />
<input type="text" id="value2" name="value2"/><br />
<input type="text" id="value3" name="value3"/><br />
<input type = "button"
onclick="Boo()"
value = "Compare!"/>
<!-- onclick="Max(document.getElementById('value1').value,
document.getElementById('value2').value,
document.getElementById('value3').value)" -->
</form>
</body>
</html>