Ver Mensaje Individual
  #9 (permalink)  
Antiguo 06/11/2010, 06:19
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Agregar Texto A Un Textarea

primero y mas importante, él está usando dom, cosa que en tu ejemplo has obviado. segundo punto, si ejecutas tu ejemplo y abres la consola de errores de firefox verás que el contenido del textarea no ha cambiado. prueba esto, revisando la firebug
Cita:
<html>
<head>
<script type="text/javascript">
function actualizar(textarea)
{
textarea = document.getElementById(textarea);
var text= document.createElement('textarea');
text.style.width = textarea.offsetWidth+'px';
text.style.height = textarea.offsetHeight+'px';    
//text.value = 'el texto ha cambiado' // falso, produce esto <textarea style="width: 105px; height: 71px;"></textarea>
text.textContent = 'el texto ha cambiado' // verdad, produce esto otro <textarea style="width: 105px; height: 71px;">el texto ha cambiado</textarea>      
textarea.parentNode.replaceChild(text,textarea);

}
</script>

</head>
<body>
<textarea id='abc' cols="10" rows="3">hola</textarea>
<button onclick="actualizar('abc')">cambia</button>
</body>
</html>