Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/03/2010, 14:58
kepawe
 
Fecha de Ingreso: agosto-2004
Mensajes: 157
Antigüedad: 19 años, 8 meses
Puntos: 5
Respuesta: copiar y pegar a otro campo solo una parte del texto

Hola pichichus14 y Adler

Código:
<html><head>
<script language="javascript">
function copiar(fuente, destino){
 var msk = /[\?&]v=([^\s&]+)/g; 
 var value = ''; 
 if(fuente.match(msk)) {

	 value = RegExp.$1; 
 }
 destino.value= "{youtube}"+ value +"{/youtube}";
}
</script>

</head><body>

<form>
<input name="direccion" type="text" id="direccion" value='http://www.youtube.com/watch?v=xitFS24joao' >
<input type="button" value="Copiar" onClick="copiar(this.form.direccion.value, this.form.video);">
<input name="video" type="text" id="video">
</form>

</body></html>
De esta forma no te tienes que preocupar de la longitud del string y te evitara tener que preguntar de nuevo .

Salu2