2017-02-07 19 views
0

私はこのJavaScriptコードがあります。HTMLフォーム入力

function othername() { 
    var input = document.getElementById("formName".value); 
    alert('Thanks for filling that out,' + ' ' + input + '!') 
} 

そして、このhtmlコード:

<form id="form" onsubmit="return false;"> 
<input type="text" id="formName"/> 
<input type="submit" onclick="othername();" /> 

私が間違って何をしましたか?

答えて

3

<form id="form" onsubmit="return false;"> 
 
\t \t <input type="text" id="formName"/> 
 
\t \t <input type="submit" onclick="othername();" /> 
 
</form> 
 
<script> 
 
\t function othername() { 
 
\t \t var input = document.getElementById("formName").value; 
 
\t \t alert('Thanks for filling that out, ' + input + '!') 
 
\t } 
 
</script>

お知らせ閉じる括弧。

+0

これに加えて、フォームのidは 'form'だけではなく' form'です。 –

+0

@MKemp IDは実際には正しいです、私たちは入力フィールドAFAIKの値に興味があります。 – ppajer

+0

Derp、あなたは正しいです:)私はHTMLのその部分を見渡しました。 –

関連する問題