Help... I don´t know where is the error (very simple, i think!)
Dear friends.
I´m speaking from Brazil, and I´m trying click in a ckeckbox and a text appear into a textarea using php getting the data from mysql, but I don´t know where the error is.
Here is the code.
- <script type="text/javascript" src="jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("select[name=msgs]").change(function(){
$.post("texto_msgs.php",
{msgs:$("#msgs option:selected").text()},
function(valor){
$("textarea[name=texto]").val(valor);
}
)
- })
})
</script>
- <select name="msgs" id="msgs" size="8"><?php
require_once("conecta_sgv.php");
$sql="SELECT * from mensagens WHERE destinatario = '$nome'";
$qr=mysql_query($sql) or die (mysql_error());
while($ln=mysql_fetch_assoc($qr)){
echo '<option value="'.$ln['id'].'">'.$ln['titulo'].' - De:'.$ln['autor'].'</option>';
}
?>
</select>
- <textarea name="texto" id="texto" rows="10" cols="65"></textarea>
and the texto_msgs.php
<?
require_once("conecta_sgv.php");
$id=$_POST['msgs'];
$sql="SELECT * FROM mensagens WHERE id = '$id'";
$qr=mysql_query($sql) or die (mysql_error());
while($ln = mysql_fetch_assoc($qr)) {
echo $ln['mensagem'];
}
?>
anyone can please give me a light! Thanks and regards