Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/07/2016, 15:48
alvaro_trewhela
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Editar texto con JS y HTML

Ve con algo como esto a modo de ayuda:
Código HTML:
Ver original
  1.     <head>
  2.         <script type="text/javascript">
  3.         function accion(){
  4.         var box1 = document.getElementById("box1");
  5.         var box2 = document.getElementById("box2");
  6.        
  7.         box2.value=box1.value;
  8.        
  9.         var tipo = document.getElementById("tipo").value;
  10.         var size = document.getElementById("size").value;
  11.         var effect = document.getElementById("effect").value;
  12.        
  13.         box2.style.fontFamily=tipo;
  14.         box2.style.fontSize=size+"px";
  15.        
  16.             if(effect == "bold"){
  17.             box2.style.fontStyle="normal";
  18.             box2.style.fontWeight="bold";
  19.             }
  20.             else if(effect == "italic"){
  21.             box2.style.fontWeight="normal";
  22.             box2.style.fontStyle="italic";
  23.             }
  24.             else{
  25.             box2.style.fontWeight="normal";
  26.             box2.style.fontStyle="normal"; 
  27.             }
  28.         }
  29.         </script>
  30.     </head>
  31.     <body>
  32.    
  33.         <textarea id="box1"></textarea>
  34.        
  35.         <br/><br/>
  36.         Tipo: <select id="tipo">
  37.             <option value="Arial">Arial</option>
  38.             <option value="Calibri">Calibri</option>
  39.             <option value="Comic Sans MS">Comic</option>
  40.         </select>
  41.        
  42.          Tamaño: <select id="size">
  43.             <option value="12">12</option>
  44.             <option value="18">18</option>
  45.             <option value="24">24</option>
  46.         </select>
  47.        
  48.         <select id="effect">
  49.             <option value="normal">normal</option>
  50.             <option value="italic">cursiva</option>
  51.             <option value="bold">negrita</option>
  52.         </select>
  53.        
  54.          <input type="button" value="GO!!" onclick="accion();" />
  55.        
  56.         <br/><br/>
  57.        
  58.         <textarea id="box2"></textarea>
  59.    
  60.    
  61.     </body>
  62. </html>

Última edición por alvaro_trewhela; 27/07/2016 a las 20:47