ボタンを押したときに次のコードで応答を表示する方法について質問があります。ボタンが応答をトリガーしない
まずは、私はJavascriptを初めて、教授からの返事を待っていると言いましょう。私はw3schoolsのキーワード検索バーを使用してJavaScriptでいくつかの異なるキーワードと要素を分解してw3schoolsを調べ、私が持っている特定の質問については不足していました。私はw3c validator.orgにもアップロードしましたが、解釈することはあまりありませんでした。私はその後、私のWebブラウザで検査オプションを使用してみました。私はそこに18のエラーを見つけましたが、実際にそれらを理解していませんでした。 5つの異なるブラウザでコードを表示しようとしましたが、ボタンを押すと何も起こりません。何か案は?私の推測では、構文領域のいくつかのタイプですが、私はまだ私が探しているものはわかりません。どんな助けもありがとう!ありがとう。
function collectInput() {
var textbox1 =
document.getElementById('textbox'1);
// compare the value in the textbox to an empty string
if(textbox1.value == "") {
// if true, send the error message to the display point
document.getElementById('response').innerHTML
= "Hey, you didn't put anything in the box!?!";
};
};
function collectInput() {
var textbox1 =
document.getElementById('textbox1');
if(textbox1.value == "") {
document.getElementById('response').innerHTML
= "Hey, you didn't put anything in the box!?!";
} else {
document.getElementById('response').innerHTML = "You
entered: "+ textbox1.value;
};
};
<body>
<div class="wrapper">
<header><h1>Header</h1></header>
<section><h1>Section</h1>
<input type="text" id="textbox1">
<input type="button" id="theButton" value="Send to the Script!" onclick="collectInput()">
<p id="response"></p><!-- the display point, the place to send the response message -->
</section>
</div>
</body>
<footer>
<p class="copy">Copyright (c) 2014 All Rights Reserved</p>
</footer>
あなたは同じ名前の2つの機能を持っていたときに最初のものは無視されるように、ロードされた最後のものは、以前に置き換えられます。 – Bindrid