Reputation: 83
I have been trying for so long and I can't find the problem.
The getelementbyId takes correctly data from two first ids: 'odbiorca' and 'temat' and it correctly add it to database, but it doesn't happen in the case of textarea 'tresc'.
Can somebody please help me?
<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>
and heres the ajax for it
<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>
Does anybody know why odbiorca.value
and temat.value
works correct, but tresc.value
doesn't?
Upvotes: 3
Views: 1977
Reputation: 198
you should change your code like below. The
<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>
Upvotes: 2