2
我一直在嘗試這麼久,我找不到問題。document.getElementById不能使用textarea
的從的getElementById兩個第一IDS正確獲取數據:「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>
和繼承人的阿賈克斯它
<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
不?
如果你正在使用'$ .ajax'和jQuery爲什麼不使用'$( '#tresc_area')。VAL()'?除非我錯過了這裏的東西 – frictionlesspulley
我猜你的'textarea'元素尚未在文檔的DOM中,當你的腳本正在尋找它時。你的JavaScript位於'textarea'之前還是之後? – Gumbo
它是在textarea之後,當它在textarea之前它也不工作 –