2017-03-25 12 views
-3

スクリプトのページにボタンを追加したいが、それはうまくいかない。私はHTMLでこれを行うことはできませんので、助けてください!document.write(smth)doesnt work

<script type="text/javascript"> 
document.write(' 

<p>Sign in</p> 
    <form action="/chat" method="GET"> 
     <p> Login: <input type="text" name="login"/> </p> 
     <p> Password: <input type="text" name="password"/> <input type="submit" value="Ok"> </p> 
    </form> 
    <br> 
    <form action="/signup"> 
     <button type = "submit"> button for registration</button> 
    </form>'); 
+3

。それはあなたが複数行の文字列をどうやって行うのではないのです。他にも問題がありますが、少なくともいくつかの言語の基本から始まります。 –

答えて

0

インタープリタはこれが新しいコード行だと思うので、機能コードには入力できません。

document.write('<p>Sign in</p><form action="/chat" method="GET"><p> Login: <input type="text" name="login"/> </p><p> Password: <input type="text" name="password"/> <input type="submit" value="Ok"> </p></form><br><form action="/signup"><button type = "submit"> button for registration</button</form>'); 
2

がそのようなHTMLをしてください印刷しますが、この問題を修正する必要がありES6 back ticksを使用してから離れて滞在:こと チェック。いくつかの基本的なJSの構文チュートリアルは順番になっている可能性があり

document.write(` 
 
    <p>Sign in</p> 
 
    <form action="/chat" method="GET"> 
 
    \t <p> Login: <input type="text" name="login"/> </p> 
 
    \t <p> Password: <input type="text" name="password"/> <input type="submit" value="Ok"> </p> 
 
    </form> 
 
    <br> 
 
    <form action="/signup"> 
 
    \t <button type = "submit"> button for registration</button> 
 
    </form> 
 
`);

関連する問題