[Javascript] firing submit event

Ben Curtis Quixote at LaMancha.org
Thu Aug 9 17:28:37 CDT 2001


> I've tried firing it on the "onkeyup" event, but it submits the form
> multiple times (one for each character in the bar code). It looks like it is
> working, but it's actually submitting multiple times.

I think you're on the right track.

Make a delay that is triggered onkeyup, and it fires the submit if the value
in the field is the same as when triggered.

onkeyup="setTimeOut('if (\''+this.value+'\' ==
document.formname.elementname.value) document.formname.submit();', 500);"

This will be triggered for every "keystroke" but will only submit if no
additional keystrokes happen for half a second (500 milliseconds). You may
need to adjust this delay, based on your bar readers.

If the barcode is always the same number of digits, say 23, then you can do
this instead:

onkeyup="if (this.value.length == 23) document.formname.submit();"

--
+Ben Curtis

"Most people use statistics the way a drunkard uses a lamp post,
more for support than illumination."









More information about the Javascript mailing list