Connecting Tech Pros Worldwide Help | Site Map

Barcode reader + WWW

Piotr Nowak
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi
i need a script that will auto-submit a form when someone enters 11
characters into one of textfields..

any ideas?
Thanks ;-)

Peter


McKirahan
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Barcode reader + WWW


"Piotr Nowak" <piotrus@withoutthispocztal.com> wrote in message
news:jTWLb.7813$oM.4722@newssvr16.news.prodigy.com ...[color=blue]
> Hi
> i need a script that will auto-submit a form when someone enters 11
> characters into one of textfields..
>
> any ideas?
> Thanks ;-)
>
> Peter[/color]

Perhaps:

<html>
<head>
<title>keypress.htm</title>
<script type="text/javascript">
function eleven(that) {
if (that.value.length == 11) {
document.form1.submit();
}
}
</script>
</head>
<body>
<form action="keypress.htm" method="get" name="form1">
<input type="text" onkeypress="eleven(this)">
</form>
</body>
</html>


Piotr Nowak
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Barcode reader + WWW


thanks... that's what i needed ;-)

Pete


HikksNotAtHome
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Barcode reader + WWW


In article <jTWLb.7813$oM.4722@newssvr16.news.prodigy.com>, "Piotr Nowak"
<piotrus@withoutthispocztal.com> writes:
[color=blue]
>Hi
>i need a script that will auto-submit a form when someone enters 11
>characters into one of textfields..
>
>any ideas?[/color]

And if the 11th character is a tyop? (Yes, thats an intentional typo).
--
Randy
Piotr Nowak
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Barcode reader + WWW


> Perhaps:

nope... it does not work the way it should...
if i set it to 10 characters, person has to enter 10 chars, the form is
being submitted, but only 9 characters are submitted. It cuts the last
character.

any ideas?


Piotr Nowak
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Barcode reader + WWW


> And if the 11th character is a tyop? (Yes, thats an intentional typo).

it will be string fed by a barcode reader

Pete


HikksNotAtHome
Guest
 
Posts: n/a
#7: Jul 20 '05

re: Barcode reader + WWW


In article <l7_Lb.15949$Rc4.64217@attbi_s54>, "Piotr Nowak"
<piotrus@pocztal.com> writes:
[color=blue][color=green]
>> Perhaps:[/color]
>
>nope... it does not work the way it should...
>if i set it to 10 characters, person has to enter 10 chars, the form is
>being submitted, but only 9 characters are submitted. It cuts the last
>character.
>
>any ideas?[/color]

us the onkeyup or onchange of the field instead of the onkeypress. onkeypress
fires as soon as the key is pressed, not after its released. And it may be a
timing issue where the key is pressed, and before its released the form is
submitted.

Personally, I would use the onchange event and when the field gets changed, and
exited, the form would submit.
--
Randy
Piotr Nowak
Guest
 
Posts: n/a
#8: Jul 20 '05

re: Barcode reader + WWW


> Personally, I would use the onchange event and when the field gets
changed, and[color=blue]
> exited, the form would submit.[/color]

on change does not work at all
onkeypress, onkeydown, onkeyup - those are cutting the last character.

any other ideas? :)



Piotr Nowak
Guest
 
Posts: n/a
#9: Jul 20 '05

re: Barcode reader + WWW



"actually when i set
if (that.value.length == 3) {

it submits 3 characters, but i have to enter 4 to submit that form., nothing
happens after entering 3rd char.
after 4th form is submitted but i have only 3 chars submitted..



Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#10: Jul 20 '05

re: Barcode reader + WWW


Piotr Nowak wrote:
[color=blue][color=green]
>> And if the 11th character is a tyop? (Yes, thats an intentional typo).[/color]
>
> it will be string fed by a barcode reader[/color]

Sorry, if you suggest that the read data should be submitted
immediately without user control, you have no clue of how
barcode readers (can) (mal)function. Let it be a bug (real
or electronical) on the barcode and your whole data is garbled.

I strongly recommend against such an automatism.


PointedEars
Closed Thread


Similar JavaScript / Ajax / DHTML bytes