1

間違って検索しているか、答えが見つからないかのどちらかです。

JSPを使用して簡単なチャットアプリケーションを作成したいと思います。1つのフィールド(入力)からテキストを取得し、それを大きなテキスト領域(出力)に追加してから、テキストフィールド(入力)をクリアしてページを更新したいと思います。各エントリは、独自の行にある必要があります。

Javaから来ているので、これは非常に紛らわしいようです。私はかなり長い間、Javaを試して理解しようとしています。私を手伝ってくれますか?

<html>
    <head>
        <script>
            function send() {

            }
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Simple Chat</title>
    </head>
    <body>
        <h1>Simple Chat</h1>
        <textarea rows="30" cols="100" name="output">Welcome to the Chat!</textarea>
        <form name="input">
            <input type="text" name="input">
            <input type="button" name="sendBtn" value="Send" onClick="send()">
            <input type="button" name="refreshBtn" value="Refresh" onClick="location.href='chat.jsp'">
        </form>
    </body>
</html>
4

1 に答える 1

1
<!DOCTYPE html>
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
        <script>
            function send() 
            {
                $("#txtArea").append("\n" + $("#txt").val());
                $("#txt").val("");
            }
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Simple Chat</title>
    </head>
    <body>
        <h1>Simple Chat</h1>
        <textarea id="txtArea" rows="30" cols="100" name="output">Welcome to the Chat!</textarea>
        <div name="input">
            <input id="txt" type="text" name="input">
            <input type="button" name="sendBtn" value="Send" onClick="send()">
            <input type="button" name="refreshBtn" value="Refresh" onClick="location.href='chat.jsp'">
        </div>
    </body>
</html>
于 2012-12-05T13:00:16.413 に答える