Multiple submit buttons, barcode scanner and enter key
843841Aug 9 2003 — edited Aug 10 2003I'm new to web programming and a bit over my head with a project at work (programmer resigned without notice last month).
I'm designing a web page for a servlet based web application for a library catalogue system where i work. The page i'm working on uses three forms, one for each "session" (ie multiple tasks using same web page). The last form on the page has the following features:
A form with 15 text input fields and 3 submit buttons
type =submit name=submit value=reset
type =submit name=submit value=delete
type =submit name=submit value=add/change
The servlet uses the value to determine how to process the form data.
The last input field on this form is used to scan item numbers using a barcode scanner. My problem is the scanner always adds a return/enter character at the end of the item number which submits the form. The problem is the servlet gets confused and doesn't know which name/value pair to use to determine how to process the form data.
I've found a way to supress the enter character using javascript. The user can now scan the barcode, but they still have to click the "add/change" button to submit the form. The users of the sytem (who process hundreds of items in a batch) want to be able to scan the item number and have the "add/change" form button activated automatically. Is this possible using javascript events alone? I don't have any control over how the servlet works aat this stage. My script to supress the enter character from the scanner is below.
<script type="text/javascript"><!--
function noenter() {
return !(window.event && window.event.keyCode == 13); }
//--></script>
<input type="text" name="itemNumber" value="$LAST.itid" onkeypress="return noenter()">
My workplace only uses Internet Explorer and this web application is for internal use only.
I think the logic in the servlet goes like this:
If session status=3 //ie form that uses a scanner for last field variable=getParameter("submit")
If variable="reset"
process reset
Else if variable="delete"
process delete
else
process add/change
Sorry this is such a long question but the project is 12 months late and i'm the last man standing so to say.
Thanks in advance
Dominic