-
1 Attachment(s)
HTML Keypad...
Hello,
Hope someone can help me out..
Im trying to create an HTML keypad.
When a user press 4 numbers making it load a page. (../code.htm?code=_____)
I have no idea how to do this and I have been googleing to find this and can't find examples anywhere.
Does anyone know how to do this or know where I can find an example.
Take a look at the screenshot attached to this post to know what I am trying to do.
Thanks.
-
Re: HTML Keypad...
- You are going to have to create a temp variable named something like code.
- If the user presses *, then set code to "".
- Everytime a number is pressed just add the string value of the number to the variable code.
- If the length is 4, then use window.location = "../code.htm?code=" + code to redirect.
-
Re: HTML Keypad...
lol, that was fun :D:D:D:
HTML Code:
<body onload="emptyCode();">
<script type="text/javascript">
function addCode(key){
var code = document.forms[0].code;
if(code.value.length < 4){
code.value = code.value + key;
}
if(code.value.length == 4){
document.getElementById("message").style.display = "block";
setTimeout(submitForm,1000);
}
}
function submitForm(){
document.forms[0].submit();
}
function emptyCode(){
document.forms[0].code.value = "";
}
</script>
<style>
body {
text-align:center;
background-color:#333333;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#keypad {margin:auto; margin-top:20px;}
#keypad tr td {
vertical-align:middle;
text-align:center;
border:1px solid #000000;
font-size:18px;
font-weight:bold;
width:40px;
height:30px;
cursor:pointer;
background-color:#666666;
color:#CCCCCC;}
#keypad tr td:hover {background-color:#999999; color:#FFFF00;}
.display {
width:130px;
margin:10px auto auto auto;
background-color:#000000;
color:#00FF00;
font-size:18px;
border:1px solid #999999;
}
#message {
text-align:center;
color:#009900;
font-size:14px;
font-weight:bold;
display:none;
}
</style>
<form action="code.htm" method="get">
<table id="keypad" cellpadding="5" cellspacing="3">
<tr>
<td onclick="addCode('1');">1</td>
<td onclick="addCode('2');">2</td>
<td onclick="addCode('3');">3</td>
</tr>
<tr>
<td onclick="addCode('4');">4</td>
<td onclick="addCode('5');">5</td>
<td onclick="addCode('6');">6</td>
</tr>
<tr>
<td onclick="addCode('7');">7</td>
<td onclick="addCode('8');">8</td>
<td onclick="addCode('9');">9</td>
</tr>
<tr>
<td onclick="addCode('*');">*</td>
<td onclick="addCode('0');">0</td>
<td onclick="addCode('#');">#</td>
</tr>
</table>
<input type="text" name="code" value="" maxlength="4" class="display" readonly="readonly" />
<p id="message">ACCESSIGN...</p>
</form>
</body>
-
Re: HTML Keypad...
What I can't get is that sometimes we do all the work for others, for free, practically wasting out time on nothing. And in return we can't get even a simple comment or a "thanks"... :(
-
Re: HTML Keypad...
-
Re: HTML Keypad...
Dude are you kidding me!! This is fantastic!!! Thanks very much!!
-
Re: HTML Keypad...
Welcome to the forums, wellverzed. :wave:
Please remember to keep your posts relevant. This thread is over 5 years old!