Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Klawiatura ekranowa + formularz
Jarek3366
post 1.04.2015, 11:25:58
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 28.05.2007

Ostrzeżenie: (0%)
-----


Witam
Jestem początkujący w jacaScript i próbuje napisać pewien skrypt. Strona ma działać na tablecie dlatego jest to klawiatura numeryczna + formularz. Problem polega na tym ze po wpisaniu pierwszych czterech cyfr automatycznie skrypt ma nas przenieść do okna następnego i teoretycznie się tak dzieje ale po wciśnięciu kolejnej cyfry pojawiają się one w nowym jaki i w starym oknie. Proszę o pomoc oto kod:

  1.  
  2. <tr>
  3. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=1 onclick="pushButton(this.value);"></td>
  4. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=2 onclick="pushButton(this.value);"></td>
  5. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=3 onclick="pushButton(this.value);"></td>
  6. </tr>
  7. <tr>
  8. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=4 onclick="pushButton(this.value);"></td>
  9. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=5 onclick="pushButton(this.value);"></td>
  10. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=6 onclick="pushButton(this.value);"></td>
  11. </tr>
  12. <tr>
  13. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=7 onclick="pushButton(this.value);"></td>
  14. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=8 onclick="pushButton(this.value);"></td>
  15. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=9 onclick="pushButton(this.value);"></td>
  16. </tr>
  17. <tr>
  18. <td><input class="calc" type="button" style="font: 15pt Arial;width:100px; height:50px;" value=0 onclick="pushButton(this.value);"></td>
  19. <td></td>
  20. <td><input class="calc" type="button" style="font: 12pt Arial;width:100px; height:50px;" value="WYCZYŚĆ" onclick="pushButton(this.value);"></td>
  21. </tr>
  22.  
  23. function pushButton(buttonValue) {
  24. if (buttonValue == 'WYCZYŚĆ') {
  25. document.getElementById('screen').value = '';
  26. document.getElementById('screen2').value = '';
  27. document.getElementById('screen3').value = '';
  28. }
  29. else {
  30.  
  31. document.getElementById('screen').value += buttonValue;
  32.  
  33.  
  34.  
  35. if(document.getElementById('screen').value.length > 4){
  36. document.getElementById('screen2').focus();
  37. document.getElementById('screen2').value += buttonValue;
  38.  
  39. }
  40. if(document.getElementById('screen2').value.length > 2){
  41. document.getElementById('screen3').focus();
  42. document.getElementById('screen3').value += buttonValue;
  43. }
  44. }
  45.  
  46. }
  47.  
  48. </script>
  49.  
  50. </head>
  51. <body>
  52. <form>
  53. <input type="text" class="calc" id="screen" name="screen" size="3" maxlength="3" value="" />
  54. <input type="text" class="calc" id="screen2" name="screen2" size="3" maxlength="3" value="" />
  55. <input type="text" class="calc" id="screen3" name="screen3" size="4" maxlength="4" value="" /><br />
  56. </form>
  57. </body>
  58. </html>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Turson
post 1.04.2015, 12:39:56
Post #2





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

Ostrzeżenie: (0%)
-----


http://jsfiddle.net/7bdpdmrc/
Pytanie ile cyfr można wpisać w poszczególnych oknach
Go to the top of the page
+Quote Post
Jarek3366
post 1.04.2015, 12:54:53
Post #3





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 28.05.2007

Ostrzeżenie: (0%)
-----


Super dzięki o to mi chodziło exclamation.gif!!
specool.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 8.07.2025 - 07:12