Ok, here's what I did. This is just my test script, I haven't generalized the code or anything yet. In this case, I needed to watch for a beginning and end tilde in the input. I went with onKeyUp instead of onKeyPress because onKeyPress needed to get the "next" press to fire off...

<SCRIPT TYPE="text/_javascript_" language="_javascript_">
function tildeScan() {
s1 = new String(scan.productid.value);
//check and see if there are bookend tildes in the string
//if so, remove them and submit the form
firstChar = s1.substr(0,1);
lastChar = s1.substr(s1.length-1,1);
if (firstChar == "~" & lastChar == "~" & s1.length > 1) {
s1 = s1.replace(/~/g, '');
scan.productid.value = s1;
scan.submit();
}
}
</SCRIPT>

<FORM ACTION="" METHOD="GET" NAME="scan">
<INPUT TYPE="text" NAME="productid" > </FORM>

>Since the scanner is effectively typing, you can listen for onKeyXxxx events
>on the form field, and when you get the second tilde, call
>this.form.submit() to submit the form.
>
>Cheers,
>barneyb
>
>> -----Original Message-----
>> From: Tony S [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, January 06, 2004 1:21 PM
>> To: CF-Talk
>> Subject: SOT: Interesting _javascript_ Question
>>
>> Well, at least it's interesting to me. ;p
>>
>> I have an application that uses a lot of bar code scanner input via a
>> keyboard wedge. By programming the scanner to append a
>> carriage return to
>> the end of the scan, forms will get submitted (with IE anyway) or with
>> some _javascript_, the focus will be moved to the next field
>> ready fror the
>> next scan...
>>
>> I have a situation where my application will be used but the scanners
>> cannot be programmed to add the CR to the end. Instead, they
>> will always
>> prepend and append a tilde to the bar code (~23545252525~).
>>
>> Is there any way, via _javascript_, to get that final tidle
>> replaced with a
>> carriage return so the "form submit" will work with a scan? It doesn't
>> likely, but I thought I'd ask...
>>
>> ** Tony Schreiber   Man and Machine, Ltd.  
>> mailto:[EMAIL PROTECTED] **
>> ** Webmaster, IS300.NET                          
>> http://www.is300.net/ **
>> ** Developer, Simple Message Board  
>> http://www.simplemessageboard.com/ **
>>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to