2

私は長い間試してきましたが、問題を見つけることができません。

getelementbyId は、最初の 2 つの ID: 'odbiorca' と 'temat' からデータを正しく取得し、データベースに正しく追加しますが、テキストエリア 'tresc' の場合は発生しません。

誰か助けてくれませんか?

<form method="post">
    <input class="input" type="text" name="do_kogo" id="odbiorca" size="25" value="<?php print $odbiorca; ?>" />
    <input class="input" id="temat" type="text" name="temat" size="25" value="<?php print $temat; ?>"/>
    <textarea id="tresc_area" cols="45" rows="10" ></textarea>
    <input onclick="Check()" id="send_submit" type="submit" value="Send" />
</form>​

そして、そのためのajaxがあります

<script type="text/javascript">

var odbiorca = document.getElementById("odbiorca");
var temat = document.getElementById("temat");
var tresc = document.getElementById("tresc_area");

function Check() {
    $.ajax({
        type: "POST",
        url: "send_prv_msg.php",
        data: {
            do_kogo: odbiorca.value,
            temat: temat.value,
            tresc: tresc.value
        },
        success: function(odp) {
            $("p#error_box").html(odp);
        }
    });

}​

</script>

誰かが理由odbiorca.valueを知っていてtemat.value、正しく動作しますが、そうでtresc.valueはありませんか?

4

1 に答える 1

2

以下のようにコードを変更する必要があります。の

<script type="text/javascript">

function Check() {
    /*get the value in each click*/
    var odbiorca = document.getElementById("odbiorca");
    var temat = document.getElementById("temat");
    var tresc = document.getElementById("tresc_area");
    $.ajax({
        type: "POST",
        url: "send_prv_msg.php",
        data: {
            do_kogo: odbiorca.value,
            temat: temat.value,
            tresc: tresc.value
        },
        success: function(odp) {
            $("p#error_box").html(odp);
        }
    });

}​

</script>
于 2012-12-17T06:33:14.617 に答える