Ver Mensaje Individual
  #5 (permalink)  
Antiguo 18/04/2011, 06:44
Avatar de Most
Most
 
Fecha de Ingreso: marzo-2009
Mensajes: 642
Antigüedad: 15 años, 1 mes
Puntos: 6
Respuesta: pasar texto de input type text a textarea con boton

Ok ahora el problema que me he dado cuenta ahora, por que no me acordaba es de esto, el archivo donde esta el textarea esta cogido desde un iframe, como puedo hacer que pase al archivo verdadero (mensajes.php) la funcion al textarea?

el codigo:

Index.php
Cita:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script>
var x=0 // variable declarad e iniciada como cero

function operacion(){
if(x==0){
//solo entra aquí cuando x sea cero
document.getElementById("mastexto").value=document .getElementById("texto").value;
x++; // variable cambia a uno despues de copiar el texto.
} else {
//solo entra aquí cuando x sea uno
document.formulario.submit(); //aquí envias el form
}
}
</script>
</head>

<body>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="400"><iframe src="mensajes.php" id="mastexto" width="400" height="300" scrolling="no"></iframe></td>
</tr>
<tr>
<td align="center"><form id="form1" name="form1" method="post" action="ejecucion.php">
<label></label>
<label></label>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="359" bgcolor="#CCFFCC">Alias
<label>
<input name="alias" type="text" id="alias" value="<?php echo $_GET['al']; ?>" size="20" />
</label></td>
</tr>
<tr>
<td bgcolor="#CCFFFF">Mensaje
<input name="mensaje" type="text" id="texto" size="40" maxlength="250" />
<input type="submit" onclick="operacion()" name="Submit" value="Enviar" /></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>

mensaje.php
Cita:
<?php
mysql_connect("localhost","root","111222");
mysql_select_db("chatear");
//echo "<META HTTP-EQUIV='refresh' CONTENT='0; URL=mensajes.php'>";

header('refresh:2; url=mensajes.php');

?>
<link href="michat.css" rel="stylesheet" type="text/css" />


<style type="text/css">
<!--
body {
background-color: #FF9933;
}
-->
</style><table width="202" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="202">
<?php
$re=mysql_query("select * from mensajes order by id desc");
while($f=mysql_fetch_array($re)){
echo "<scpan class='fecha'></span>".$f['fecha']."&nbsp;&nbsp;<span class='usuario'>".$f['alias']."</span>:&nbsp;&nbsp;&nbsp;<span class='mensaje'>".htmlentities($f['mensaje'])."</span><br>";
}
?> </td>
</tr>
</table>

saludos.