Foros del Web » Programando para Internet » Javascript »

FUNCION copyit(theField)

Estas en el tema de FUNCION copyit(theField) en el foro de Javascript en Foros del Web. Como se puede evitar en el script siguiente, que cada vez que se seleccione un nuevo texto para añadir, se borre el que se habia ...
  #1 (permalink)  
Antiguo 26/11/2006, 05:27
 
Fecha de Ingreso: noviembre-2006
Ubicación: BARCELONA
Mensajes: 30
Antigüedad: 17 años, 5 meses
Puntos: 0
Exclamación FUNCION copyit(theField)

Como se puede evitar en el script siguiente, que cada vez que se seleccione un nuevo texto para añadir, se borre el que se habia guardado anteriormente en el textarea


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function copyit(theField) {
var selectedText = document.selection;
if (selectedText.type == 'Text') {
var newRange = selectedText.createRange();
theField.focus();
theField.value = newRange.text;
} else {
alert('seleccione texto con el cursor i pulse este botón');
}
}
// End -->
</script>


<input onclick="copyit(this.form.select1)" type="button" value="Copiar en textarea" name="btnCopy">


<textarea rows="3" name="select1" cols="64" tabindex="4"></textarea>
  #2 (permalink)  
Antiguo 26/11/2006, 08:37
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola CARLOS.asp

Código:
theField.focus();
theField.value += newRange.text;
} else {
Saludos,
  #3 (permalink)  
Antiguo 26/11/2006, 17:23
 
Fecha de Ingreso: noviembre-2006
Ubicación: BARCELONA
Mensajes: 30
Antigüedad: 17 años, 5 meses
Puntos: 0
Gracias , Resulta Bastante Evidente
  #4 (permalink)  
Antiguo 26/11/2006, 18:13
 
Fecha de Ingreso: noviembre-2006
Ubicación: BARCELONA
Mensajes: 30
Antigüedad: 17 años, 5 meses
Puntos: 0
Funciona Pero El Resultado Es:

Texto1texto2texto3....

Como Lo Hago Para Que Lo Separe Con Coma Y Espacio?:

Texto1, Texto2, Texto3

O Mejor Aun Salto De Linea:

Texto1
Texto2
Texto3
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:34.