Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/03/2010, 17:19
Bam_Margera
 
Fecha de Ingreso: febrero-2009
Mensajes: 580
Antigüedad: 15 años, 3 meses
Puntos: 13
De acuerdo Respuesta: Crear un espejo palíndromo de Textareas

Cita:
Iniciado por Adler Ver Mensaje
Hola

No le has hecho mucho caso a Panino

Prueba ahora

Código Javascript:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5.         <title>Espejo Palíndromo</title>
  6.         <script type="text/javascript">
  7.             var longitud = 0;
  8.             var indice = 0;
  9.             var origen = '';
  10.             var destino = '';
  11.            
  12.             function palindromar_caracter(){
  13.                 var text_origen = document.getElementById("origen");
  14.                                var text_destino = document.getElementById("destino");
  15.                 origen = text_origen.value;
  16. divorigen = origen.split("").reverse().join("");
  17. alert(divorigen[0]);
  18.                 destino = text_destino.value;
  19.                 var letra = divorigen[indice];
  20.                
  21.                 text_destino.innerHTML = destino + letra;
  22.                 indice = indice + 1;
  23.                
  24.                
  25.             }
  26.            
  27.            
  28.         </script>
  29.     </head>
  30.     <body>
  31.        
  32.         <textarea id="origen" name="origen">La ruta natural</textarea>
  33.         <textarea id="destino" name="destino"></textarea>
  34.         <button onclick="palindromar_caracter();">Palindromar letra</button>
  35.     </body>
  36. </html>

Suerte
Claro que le he hecho caso, por eso mismo preguntaba de qué sirve el split.. EL codigo funciona :D solo que quería intentar terminar mi código,

Bueno asi se queda

Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Espejo Palíndromo</title>
        <script type="text/javascript">
            var longitud = 0;
            var indice = 0;
            var origen = '';
            var destino = '';
            
            function palindromar_caracter(){
                var text_origen = document.getElementById("origen");
                var text_destino = document.getElementById("destino");
                origen = text_origen.value;
				divorigen = origen.split("").reverse().join("");
				destino = text_destino.value;
                var letra = divorigen[indice];
                if(indice <= (origen.length -1)){
                	text_destino.innerHTML = destino + letra;
                	indice = indice + 1;
				 }else{
					 alert("no hay más caracteres");
				  }
                
                
            }
            
            
        </script>
    </head>
    <body>
        
        <textarea id="origen" name="origen">La ruta natural</textarea>
        <textarea id="destino" name="destino"></textarea>
        <button onclick="palindromar_caracter();">Palindromar letra</button>
    </body>
</html>
Deberían dármelo por bueno.. no?

Un saludo chicos, Muchas gracias



Viva ForosDelWeb! xD
__________________
¿ya conoces la red social de cocina? descubre y comparte recetas de cocina
TONIWEB, un programador web freelance