Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/09/2015, 13:37
Avatar de As3
As3
 
Fecha de Ingreso: septiembre-2015
Mensajes: 6
Antigüedad: 8 años, 7 meses
Puntos: 0
Pregunta javascript boton de borrado de teclado virtual

Hoola amigos estoy haciendo una pagina web sobre ejercitación de matemáticas y soy muy newby en esto de la programación, así que necesito de su gentil ayuda... Estuve viendo algunos tutoriales de JS y no entendí tanto como debería Quería crear un tecladito virtual para escribir lenguaje matemático, esto fue lo que pude hacer, pero no tengo idea de como arreglar este código para agregar un botón que borre dígito a dígito y no que borre todo lo que se escribió en el cuadro de texto... Si saben como se hace les agradezco su ayuda :D
PD: También quiero saber si se puede combinar teclear letras con el teclado de la pc alternando con los simbolos del teclado virtual y que queden en el value

Código HTML:
Ver original
  1. <!doctype html>
  2. <meta charset="utf-8">
  3. <title>Documento sin título</title>
  4. // JavaScript Document
  5. var cifra="";
  6. var valores=[];
  7. function display_ecuacion(num){
  8.     valores.push(num);
  9.     document.getElementById("display").value =cifra+num;
  10.     cifra=document.getElementById("display").value;
  11.     }
  12. function resetearDisplay(){
  13. document.getElementById("display").value ="";
  14.     cifra = "";
  15. } </script>
  16. .tamBot{
  17.     width:30px;
  18.     height:30px;
  19.     padding:2px;
  20.     font-size:150;
  21.     font-weight:bolder;
  22.     font-style:italic;
  23.     color:#181531;
  24.     background-color:#E8F7EE;
  25.     float:left;}
  26.  
  27. .tablita{
  28.     float:none;
  29.     margin:20px;
  30.     width:200px;
  31.     font-size:1em;
  32.     font-weight:400;}
  33.  
  34.  </style>
  35. </head>
  36.  
  37.  <form action="respuestas.php" name="ejercicio" method="post" enctype="multipart/form-data" >
  38.  <div class="dom">Dom( f )={</div><input name="display" type="text" id="display" class="display" required/> <div class="dom">}</div>
  39.   <input name="elreset" type="button" class="dom2" id="borro" value="Borrar" onClick="resetearDisplay()">
  40. <br><br>
  41.  
  42. <table class="tablita" border="1" >
  43.    <tr>
  44.     <td width="5%"><input name="button1" type="button"  class="tamBot" id="button1" value="x&sup2" onClick="display_ecuacion('\xB2')"></td>
  45.     <td width="5%"><input name="button2" type="button" class="tamBot" id="button2" value="x&sup3"onClick="display_ecuacion('\xB3')"></td>
  46.     <td width="5%"><input name="button3" type="button" class="tamBot" id="button3" value="=" onClick="display_ecuacion('=')"></td>
  47.     <td width="5%"><input name="button4" type="button" class="tamBot" id="button4" value="≠" onClick="display_ecuacion('\u2260')"></td>
  48.     <td width="5%"><input name="button5" type="button"  class="tamBot" id="button5" value="≤" onClick="display_ecuacion('\u2264')"></td>
  49.     <td width="5%"><input name="button6" type="button" class="tamBot" id="button6" value="≥" onClick="display_ecuacion('\u2265')"></td>  
  50.    </tr>
  51.    <tr>
  52.     <td width="5%"><input name="button7" type="button" class="tamBot" id="button7" value="∞" onClick="display_ecuacion('\u221E')"></td>
  53.     <td width="5%"><input name="button8" type="button" class="tamBot" id="button8" value="∈" onClick="display_ecuacion('\u2208')"></td>
  54.     <td width="5%"><input name="button9" type="button" class="tamBot" id="button9" value="√" onClick="display_ecuacion('\u221A')"></td>
  55.     <td width="5%"><input name="button10" type="button" class="tamBot" id="button10" value="∪" onClick="display_ecuacion('\u222A')"></td>
  56.     <td width="5%"><input name="button11" type="button" class="tamBot" id="button11" value="│x│" onClick="display_ecuacion(' \|x\|')" ></td>
  57.     <td width="5%"><input name="button12" type="button" class="tamBot" id="button12" value="ℜ" onClick="display_ecuacion('\u211C')"></td>
  58.    </tr>
  59.    <tr>
  60.     <td width="5%"><input name="button713" type="button" class="tamBot" id="button13" value="x" onClick="display_ecuacion('x')"></td>
  61.     <td width="5%"><input name="button14" type="button" class="tamBot" id="button14" value="∈" onClick="display_ecuacion('\u2208')"></td>
  62.     <td width="5%"><input name="button15" type="button" class="tamBot" id="button15" value="√" onClick="display_ecuacion('\u221A')"></td>
  63.     <td width="5%"><input name="button16" type="button" class="tamBot" id="button16" value="∪" onClick="display_ecuacion('\u222A')"></td>
  64.     <td width="5%"><input name="button17" type="button" class="tamBot" id="button17" value="│x│" onClick="display_ecuacion(' \|x\|')" ></td>
  65.     <td width="5%"><input name="button18" type="button" class="tamBot" id="button18" value="ℜ" onClick="display_ecuacion('\u211C')"></td>
  66.   </tr>
  67.  
  68.   </table>
  69.   <input type="submit" value="Corregir" class="dom2" />
  70.   </form>
  71.  </div>
  72.          
  73. </body>
  74. </html>

Última edición por Triby; 10/09/2015 a las 17:40 Razón: Quitar formato "Leéme!!!!"