sea4me
03-13-2009, 04:33 AM
I have this barcode scanner (it works just like a keyboard) and when I scan a barcode, it has this string inputted into my input text field.
It usually takes 1 sec to scan and input it so would i be able to have say onkeypress to call that function and do that function 1 sec later?
Should I use setTimeout(insertbarcode(),1000); in a function???
Here is what I have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<script type="text/javascript">
<!--
function insertbarcode()
{
var barcode = document.getElementById("barcode").value;
var code = '<input type="text" name="barcode[]" value="' + barcode + '" disabled="disabled" />';
code += "<br />";
document.getElementById("content").innerHTML = code + document.getElementById("content").innerHTML;
document.getElementById("barcode").value='';
}
-->
</script>
</head>
<body>
<input id="barcode" name="barcode" onkeydown="javascript:insertbarcode()" type="text" />
<form action="#" method="post">
<div id="content">
</div>
</form>
</body>
</html>I made ^ PHP so that it would be colored (easier to read)
When I put in the barcode, every one letter is on a new line so I was thinking of the 1 sec delay.
BTW the barcode works exactly like a keyboard.....
Can you guy help me??
I'm just a noob :o.
It usually takes 1 sec to scan and input it so would i be able to have say onkeypress to call that function and do that function 1 sec later?
Should I use setTimeout(insertbarcode(),1000); in a function???
Here is what I have so far:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<script type="text/javascript">
<!--
function insertbarcode()
{
var barcode = document.getElementById("barcode").value;
var code = '<input type="text" name="barcode[]" value="' + barcode + '" disabled="disabled" />';
code += "<br />";
document.getElementById("content").innerHTML = code + document.getElementById("content").innerHTML;
document.getElementById("barcode").value='';
}
-->
</script>
</head>
<body>
<input id="barcode" name="barcode" onkeydown="javascript:insertbarcode()" type="text" />
<form action="#" method="post">
<div id="content">
</div>
</form>
</body>
</html>I made ^ PHP so that it would be colored (easier to read)
When I put in the barcode, every one letter is on a new line so I was thinking of the 1 sec delay.
BTW the barcode works exactly like a keyboard.....
Can you guy help me??
I'm just a noob :o.