Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/08/2009, 07:26
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: teclado virtual numerico

Hola

A ver que te parece

Código javascript:
Ver original
  1. <html>
  2. <head>
  3. <title>teclado en pantalla</title>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. <script language="JavaScript" type="text/javascript">
  7. // Comprueba Navegador y Plataforma del pc
  8. var clientPC = navigator.userAgent.toLowerCase(); // Coge info cliente
  9. var clientVer = parseInt(navigator.appVersion); // Coge versión navegador
  10.  
  11. var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
  12. var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
  13.                 && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
  14.                 && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
  15. var is_moz = 0;
  16.  
  17. var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
  18. var is_mac = (clientPC.indexOf("mac")!=-1);
  19.  
  20. function imprm(bot) {
  21. var txtarea = document.getElementById('ta');
  22. var tecla = new Array('1','2','3','4','5','6','7','8','9','0','q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','ñ','z','x','c','v','b','n','m',',','.','-','\n',' ','              ');
  23. txtarea.value+=tecla[bot];
  24. txtarea.focus();
  25. return;
  26. }
  27.  
  28. function imprM(bot) {
  29. var txtarea = document.getElementById('ta');
  30. var teclaM = new Array('!','"','·','%','/','(',')','=','?','¿','Q','W','E','R','T','Y','U','I','O','P','A','S','D','F','G','H','J','K','L','Ñ','Z','X','C','V','B','N','M',';',':','_','\n',' ','              ');
  31. txtarea.value+=teclaM[bot];
  32. txtarea.focus();
  33. return;
  34. }
  35.  
  36.  
  37. var capa1
  38. var capa2
  39. var ns4 = (document.layers)? true:false
  40. var ie4 = (document.all)? true:false
  41. var ns6 = (document.getElementById)? true:false
  42.  
  43. function teclado() {
  44.    if (ns4) {
  45.      capa1 = document.c1
  46.      capa2 = document.c2
  47.   }
  48.  if (ie4) {
  49.    capa1 = c1.style
  50.    capa2 = c2.style
  51.  }
  52.  if (ns6) {
  53.    capa1 = document.getElementById('c1').style
  54.    capa2 = document.getElementById('c2').style
  55.  }
  56. }
  57.  
  58. function muestra(obj) {
  59. if (ns4) obj.visibility = "show"
  60. else if (ie4) obj.visibility = "visible"
  61. else if (ns6) obj.visibility = "visible"
  62. }
  63. function oculta(obj) {
  64. if (ns4) obj.visibility = "hide"
  65. else if (ie4) obj.visibility = "hidden"
  66. else if (ns6) obj.visibility = "hidden"
  67. }
  68.  
  69.  
  70. function borrar() {
  71. var txtarea = document.getElementById('ta');
  72. if ((clientVer >= 4) && is_ie && is_win) {
  73. var txtSeleccion = document.selection.createRange().text;
  74.  
  75.     if (document.selection) {
  76.  
  77.         if (!txtSeleccion) {
  78.         txtarea.focus();
  79.         var Sel = document.selection.createRange();
  80.         Sel.moveStart ('character', -txtarea.value.length);
  81.         curPos = Sel.text.length;
  82.         txtarea.value=txtarea.value.substr(0,txtarea.value.length-1);
  83.         alert("posicion1: "+curPos);
  84.         return(curPos);
  85.         }
  86.  
  87.         txtarea.focus();
  88.         var Sel = document.selection.createRange();
  89.         document.selection.createRange().text = "";
  90.         Sel.moveStart ('character', -txtarea.value.length);
  91.         curPos = Sel.text.length;
  92.         alert("posicion2: "+curPos);
  93.         return(curPos);
  94.     }
  95. }
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
  103.  
  104.     {
  105.  
  106.     var selLargo = txtarea.textLength;
  107.     var selEmpz = txtarea.selectionStart;
  108.     var selFin = txtarea.selectionEnd;
  109.     var s1 = (txtarea.value).substring(0,selEmpz);
  110.     var s2 = (txtarea.value).substring(selFin, selLargo);
  111.     txtarea.value =  s1 +  s2;
  112.     alert("posicion3: "+selEmpz);
  113.     return(selEmpz);   
  114.  
  115. }
  116. else
  117. {
  118.  
  119.     var selLargo = txtarea.textLength;
  120.     txtarea.value = txtarea.value.substr(0,txtarea.value.length-1);
  121.     var Cursor = txtarea.textLength;
  122.     alert("posicion4: "+Cursor);
  123.     return(Cursor);
  124.  
  125. }
  126.     almznaCursor(txtarea);
  127. }
  128.  
  129. function almznaCursor(textEl) {
  130.     if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
  131. }
  132.  
  133.  
  134. function PosicionCursor(pos) {
  135. var txtarea = document.getElementById('ta');
  136.  
  137.     //Firefox
  138.     if (txtarea .setSelectionRange) {
  139.         txtarea .focus();
  140.         txtarea .setSelectionRange(pos,pos);
  141.     }
  142.     else if (txtarea .createTextRange) {
  143.         var rango = txtarea .createTextRange();
  144.         rango.collapse(true);
  145.         rango.moveEnd('character', pos);
  146.         rango.moveStart('character', pos);
  147.         rango.select();
  148.     }
  149. }
  150.  
  151. function EliminarCaracter()
  152. {
  153.     PosicionCursor(borrar());
  154. }
  155.  
  156. </script>
  157. <style type="text/css">
  158. <!--
  159. .posLay1 {
  160.     position:absolute;
  161.     visibility:visible;
  162.     left:10px;
  163.     top:190px;
  164. }
  165.  
  166. .posLay2 {
  167.     position:absolute;
  168.     visibility:hidden;
  169.     left:10px;
  170.     top:190px;
  171. }
  172.  
  173. input{width:20px; height:20px; text-align:center; font-size:10px;}
  174. -->
  175. </style>
  176. </head>

continua en el siguiente post
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />