Im having a wierd problem that may or may not be related to Javascript. I created the following script. It is a mixture of Javascript and ASP.
The function is supposed to read a text field after the 13th character it either increments a text box or throws an alert saying the number was entered to many times. Works great when the number is typed. The problem is when when the number is put in with a barcode scanner. It will throw the alert message. But only for a second and keep running the script. Can someone have a look at this and tell me if Im doing something wrong w/the script. This way Ill know if it is the scanner doing something, in which case I have go down that road.
AJ
Do you feel lucky?
The function is supposed to read a text field after the 13th character it either increments a text box or throws an alert saying the number was entered to many times. Works great when the number is typed. The problem is when when the number is put in with a barcode scanner. It will throw the alert message. But only for a second and keep running the script. Can someone have a look at this and tell me if Im doing something wrong w/the script. This way Ill know if it is the scanner doing something, in which case I have go down that road.
Code:
<SCRIPT LANGUAGE="JavaScript">
Test = 0;
Count = <%=BarcodeCount%>;
SubmitCnt = 0;
Qty = new Array();
TotalQty = new Array();
for (i = 1; i <= Count; i++)
{
Qty[i] = 0;
TotalQty[i] = WorkQueue['Qty_' + [i]].value;
WorkQueue['ScanTotal_' + [i]].value = 0;
}
function CheckBarCode(formname)
{
if (formname.DOS.value.length == 13)
{
barcodelist = formname.barcodelist.value;
barcodecount = formname.barcodecount.value;
barcode = barcodelist.split(" ");
for (i = 0; i < barcodecount; i++)
{
if (formname['Bar_' + barcode[i]].value == formname.DOS.value)
{
Qty[i+1]++;
if (Qty[i+1] > TotalQty[i+1])
{
Sendalert()
}
else
{
formname['ScanTotal_' + [i+1]].value = Qty[i+1];
SubmitCnt ++;
if (SubmitCnt == <%=TotalQty%>)
{
formname.submit();
}
}
}
}
formname.DOS.value = "";
}
}
function Sendalert()
{
alert("To many products scanned");
return false;
}
</script>
AJ
Do you feel lucky?