Forum Moderators: open
The problem is that this ENTER is causing the "SUBMIT" button to be pressed. I want to somehow strip the ENTER key from each scan and fill a form, and then have the user click on the SUBMIT form. I know very little Javascript. Is this possible?
In javascript, your string would be represented by "123-456\n". "\n" is known as the end-of-line which will generally work for carriage-return+line-feed also.
If you search for that string, you need to add an extra backslash, for example:
myText.replace(/\\n/g, '')
would strip the end-of-line.
[edited by: MarkFilipak at 8:59 pm (utc) on Mar. 6, 2008]
Name:
Address:
City:
But the user enters "John Wayne<ENTER>" and the form is submitted prematurely. I need to somehow capture that ENTER key "on the fly". Either that or disable the SUBMIT button from being "pressed" with the enter key.
<input type="submit" ...>
<input type="button" onclick="document.yourFormsName.submit();" ...>
If you are using form validation, then preferably call that first, and then submit the form, but that's just a minor inconvenience.
This will make the Enter/Return key do nothing, because the browser will not know what is the "default" action to do, so it discards that. You can achieve the same (although not that reliable) effect by adding more the one submit buttons to your form (to confuse the browser; but I'd not count on that).
onsubmit="return validateForm();"
function validateForm(){
...are all fields filled out?...
yes ? return true : return false;
}
If it's a set # of fields and you know a certain # of <ENTER>s are going to be sent, then you could also just use a global count. Or, instead of validating all of the boxes, maybe you could just validate the last one?
vol7ron
[edited by: vol7ron at 10:37 pm (utc) on Mar. 7, 2008]
<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
numcheck = /\d/;
return !numcheck.test(keychar);
}
</script>
<form>
<input type="text" onkeypress="return noNumbers(event)" />
</form>
</html>
You might be able to modify it so that in place of numcheck = /\d/ you can try the /\n/ as Mark suggested. Notice how this is using a window event.
vol7ron
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}document.onkeypress = stopRKey;
...does the node.type have to equal text? It's form submission rather than text-box.
By the look turbosaab's method could also be used to solve the OP's problem of form submission (without modification) if barcode scanners "perform EXACTLY as if someone is typing on the keyboard" - I assume using a text box?
But in general terms I don't think the node.type needs to be limited to "text". "radio" and "checkbox" could also be useful. However, it would be wrong to surpress the enter key on some elements. <textarea> for instance does not cause a submit if the enter key is pressed and indeed it is useful here. Also if the user was able to TAB to the submit button, then hitting enter would naturally action it.
Mark: I've kind of given up because it's a little over my head. I've already installed Xampp on my Laptop, so I have access to my website and database "offline". Maybe I don't want to use a web form at all for this. I basically would like it to work like a cash register... I scan an item, and it pulls up the price (which I can edit if someone wants to bargain with me as they do), then I can scan the next item and however many items there are, and only then click the TOTAL key or whatever. So I'm looking to record the items sold at the show, preferably record the price paid next to each item, and the final wishlist would be to total the transaction for that sale, so I don't ALSO have to fidgit with a calculator to get the total. It can be a fast moving environment at times. Oh yeah... I also need to make it fairly simple for my wife... no having to manually "focus" on the current form field.
vol7ron: We're using MySQL on a shared Linux server. Anyway, we're out trade shows WITHOUT Internet access.
I do not understand what you're saying here. Access is an application that can be used w/o the internet. It is a standalone app. I'm not as familiar with using Access on Linux, but Open Office should have a comparable product. If not, there should be some sort of form submission with a background scripting language that can handle this request on the road.
In any case, if you are not using the internet to perform this task, you should look at using HTAs (HTML Applications) to perform your task. Though, I think the biggest problem is with the interface.
When you get home upload Microsoft Access to your mySQL or Access Db you have online. Use the database form as your driver for this, not your html form. (My personal opinion)
The real question is, since you're on the road, why can't you just scan to a CSV or txt file and import the data later?
I looked at and tried a few POS open source programs, and they either use their own proprietary database system with no import function (we have 800 different items), or they require scanning, then tabbing over a bunch of fields to get to the next line for each item. It's going to be too much in a busy environment.
I will also explore the Access method.
The POS input form should be configurable. Maybe you didn't look hard enough.
> they too will access the database...
Uh-oh! Record locking time! Forget Excel. Maybe even forget Access.
[edited by: MarkFilipak at 10:41 pm (utc) on Mar. 12, 2008]
But you see my problem right? Lets say I've got Excel on the screen, and the next open cell is ready to go. My helper clicks on our database to check something for a customer. The place is busy and frantic. He forgets to click back to Excel and make sure the cursor is at the next empty cell. It seems like a recipe for disaster.
The POS software I looked at was horrible. Most I found in my search were Linux based.
1) Why does the text file have to be constantly open? Can't you just configure it to write to the file without it another application having it open.
2) Did the scanner come with any software? I would assume there would be a way to change the focus if a scan has been performed, or even the fact that you can input directly to a file, without any application at all.
As for record-locking, this would only be a problem if two people were updating a record at the same time. More-than-likely a table level lock would not be needed, a dbms such as Access should be able to input from multiple sources at the same time.
PostgreSQL is a strong free database available on Linux, there is an open-source project dealing with forms, which I haven't used yet, but might be worth taking a look at. The good thing about PostgreSQL is the ability to work with whatever language you're comfortable with (C,Java,Perl). I think Perl would be the most robust.