|
查看: 2285|回复: 6
|
JQUERY 的數字鍵盤
[复制链接]
|
|
|
因為最近有1個CASE 要用到 數字鍵盤 (無鍵盤的touch screen) ,
參考了一些別人的教學 , 寫了個簡單的數字鍵盤 , 可是卻沒辦法將他用在同一個form 裡面的其他的form type="text" ,
(因為 沒鍵盤的關係 , 所以一定要點 [螢幕的數字鍵盤])
請問有人可以指點一下/給個方向嗎 ?
- <html>
- <head>
- <title> New Document </title>
- <meta name="Generator" content="EditPlus">
- <meta name="Author" content="">
- <meta name="Keywords" content="">
- <meta name="Description" content="">
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
- <style>
- button { margin:4px; cursor:pointer; }
- </style>
- </head>
- <body>
-
- <form action='cash_in_process.php' method='POST'>
- <label>Currency</label>
-
-
- <label>Amount</label><br>
- <input type='text' name='amount' class='text' id='amount'><br>
-
- <label>Number 2</label><br>
- <input type='text' name='amount' class='text' id='a2'><br>
- <label>Number 3</label><br>
- <input type='text' name='amount' class='text' id='a3'><br>
-
- <input type='submit' value='Submit'>
-
-
- </form>
- </div>
- <div class='span-10 ' align='center'><br><br><br>
-
- <button style='font:bold 50px verdana' id='bt' >7</button><button style='font:bold 50px verdana' id='bt'>8</button><button style='font:bold 50px verdana' id='bt'>9</button><br>
- <button style='font:bold 50px verdana' id='bt'>4</button><button style='font:bold 50px verdana' id='bt'>5</button><button style='font:bold 50px verdana' id='bt'>6</button><br>
- <button style='font:bold 50px verdana' id='bt'>1</button><button style='font:bold 50px verdana' id='bt'>2</button><button style='font:bold 50px verdana' id='bt'>3</button><br>
- <button style='font:bold 50px verdana' id='bt'>0</button><button style='font:bold 50px verdana' id='bt'>.</button><button style='font:bold 50px verdana' id='bt'><</button><br>
- </div>
- <script>
- var sum="";
- $("button#bt").click(function(){
-
- var text=$(this).text();
- if(text=='<'){
- sum = sum.substr(0,sum.length-1);
- }
- else{
- sum=sum+text;}
- $("input#amount").val(sum);
-
- });
- </script>
复制代码 |
|
|
|
|
|
|
|
|
|
|
发表于 31-8-2010 12:33 PM
|
显示全部楼层
不明白....
但是有地方要改
textVal = "99"
textVal+1 = 991
parseInt(textVal)+1 = 100 |
|
|
|
|
|
|
|
|
|
|
发表于 1-9-2010 11:03 PM
|
显示全部楼层
因為最近有1個CASE 要用到 數字鍵盤 (無鍵盤的touch screen) ,
參考了一些別人的教學 , 寫了個簡單的數 ...
雷洛 发表于 22-8-2010 08:50 AM 
你全部button 用同样的id好像不行哦,用class='bt',id='bt1','bt2' so on ...然后script 里的
$("button#bt").click(function(){
改成
$("button.bt").click(function(){ |
|
|
|
|
|
|
|
|
|
|
发表于 2-9-2010 11:07 PM
|
显示全部楼层
本帖最后由 小陈陈 于 2-9-2010 11:08 PM 编辑
因為最近有1個CASE 要用到 數字鍵盤 (無鍵盤的touch screen) ,
參考了一些別人的教學 , 寫了個簡單的數 ...
雷洛 发表于 22-8-2010 08:50 AM 
- <html>
- <head>
- <title> New Document </title>
- <meta name="Generator" content="EditPlus">
- <meta name="Author" content="">
- <meta name="Keywords" content="">
- <meta name="Description" content="">
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
- <style>
- button { margin:4px; cursor:pointer; }
- </style>
- </head>
- <body>
- <form action='cash_in_process.php' method='POST'>
- <label>Currency</label><br/>
- <label>Number 1</label><br>
- <input type='text' name='number1' id='number1' class='text' onclick='getfocus("number1")'><br>
- <label>Number 2</label><br>
- <input type='text' name='number2' id='number2' class='text' onclick='getfocus("number2")'><br>
- <label>Number 3</label><br>
- <input type='text' name='number3' id='number3' class='text' onclick='getfocus("number3")'><br>
- <input type='submit' value='Submit'>
- <input type='hidden' name='field' id='field' value='number1'>
- </form>
- <div class='span-10 ' align='center'><br><br><br>
- <button style='font:bold 50px verdana' id='bt'>7</button><button style='font:bold 50px verdana' id='bt'>8</button><button style='font:bold 50px verdana' id='bt'>9</button><br>
- <button style='font:bold 50px verdana' id='bt'>4</button><button style='font:bold 50px verdana' id='bt'>5</button><button style='font:bold 50px verdana' id='bt'>6</button><br>
- <button style='font:bold 50px verdana' id='bt'>1</button><button style='font:bold 50px verdana' id='bt'>2</button><button style='font:bold 50px verdana' id='bt'>3</button><br>
- <button style='font:bold 50px verdana' id='bt'>0</button><button style='font:bold 50px verdana' id='bt'>.</button><button style='font:bold 50px verdana' id='bt'><</button><br>
- </div>
- <script>
- $("button#bt").click(function(){
- var c = $("#field").val();
- var text=$(this).text();
- var sum = document.getElementById(c).value;
- if(text=='<'){
- sum = sum.substr(0,sum.length-1);
- }else{
- sum=sum+text;
- }
- document.getElementById(c).value = sum;
- });
- function getfocus(a) {
- $("input#field").val(a);
- }
- </script>
-
复制代码
乱来的~  |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 10-9-2010 05:48 PM
|
显示全部楼层
回复 2# ~废材~
因為這個不是計算機 , 只是為了代替鍵盤輸入的 一個數字鍵盤 , 不具備+, -, x, / 的功能 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 10-9-2010 05:49 PM
|
显示全部楼层
回复 3# keat8303
好像沒有影響到結果的樣子 ....XD |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 10-9-2010 05:52 PM
|
显示全部楼层
回复 4# 小陈陈
阿....跟我得到的解答很接近@Q@, 其實我10天前有網友告訴過我解答了跟你說得很接近.
感謝各位的回答 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|