偶尔的坏扫描仪输入

时间:2013-12-05 15:11:30

标签: jquery html ajax asp-classic

我的网站上有跟踪功能。用户扫描项目时,将保存扫描。很容易。它在过去的6个月里一直运作良好。

我有一些用户在扫描时,扫描的输入会被更改,但字符串中只有一个字符。

实施例: 条形码是W7411A-004ZT-LX

有时它会正确扫描: W7411A-004ZT-LX 有时它会替换一个字符,在本例中为第二个字符,并扫描为: W%411A-004ZT-LX

扫描仪是Symbol LS4208。

提前致谢! 马特

我的输入框:

<input type="text" id="kitID" />

我的jQuery:

$('#kitID').keypress(function(e){
    var kit = $('#kitID').val();

    if ( e.keyCode == 13 && kit.length > 3 ){
        addKit();
    }
    if ( e.keyCode == 9 && kit.length > 3 ) {
        addKit();
        $('#kitID').focus();
    }
});

$('#kitID').keyup(function(){
    var kit = $('#kitID').val();
    var pgrm = $('#ddPgrm').val();
    var charOne = kit.substr(0,1);
    var charLast = kit.substr(kit.length - 1, 1);
    var charDash = kit.substr(kit.length - 3,1);

    if ( kit.length > 1 ) {
        $('#cmdKit').show();
        if (( pgrm == 'XX4' && charOne == 'R' ) || ( pgrm == 'XX7' && charOne == 'W' )) {
            if ( charLast == 'I' || charLast == 'O' || charLast == 'X' ) {
                if ( charDash == '-' ) {
                    addKit();
                    $('#kitID').focus();
                }
            }
        }
    } else {
        //$('#cmdKit').hide();
    }
    $('#kitID').focus();
});

function addKit(){
    var rack = $('#rackID').val();
    var kit = $('#kitID').val();
    var rackVal = $('#rackVal').val();
    var Loc = $('#ddLoc').val();
    var LocII = $('#ddLocII').val();
    var pgrm = $('#ddPgrm').val();
    var jRsn = $('#jailRsn').val();
    /*var charOne = kit.substr(0,1);
    var charLast = kit.substr(kit.length - 1, 1);*/

    kit = kit.toUpperCase();

    var i = 0;
    while ( i = 0 ) {
        if ( kit.substr(0,1) == ' ' ) {
            kit = kit.substr(1,kit.length);
        } else {
            i ++;
        }
    }

    if ( kit.substr(0,3) == 'IP-' ){
        alert('Scan the kit barcode #, not the IP number.');
    } else if ( ( Loc == 50 || Loc == 51 ) && jRsn == '' ) {
        //$('#jailRsn').focus();
        alert('Enter the reason for Jailing.');
    } else {
        var i = 0;
        while ( i = 0 ) {
            if (kit.substr(0,1) != 'R' || kit.substr(0,1) != 'V' || kit.substr(0,1) != 'W' ) {
                kit = kit.substr(1,kit.length);
            } else {
                i ++;
            }
        }
        if ( rackVal == 'NR' ) {
            $.ajax({
                url:"kitSystem.asp?Kit="+kit+"&uT=10",
                success: function(responseText){
                    $.ajax({
                        url:'kitSystem.asp?Kit='+kit+'&KitEx='+responseText+'&Loc='+Loc+'&LocNm='+ LocII +'&Pgrm='+pgrm+'&jRsn='+ encodeURIComponent(jRsn) +'&uT=11'
                    });
                }
            });
            var inMKM = 0;
            $.ajax({
                type:"post",
                url:"kitSystem.asp?Kit="+kit+"&uT=112",
                dataType:"xml",
                async:false,
                success: function(xml){
                    $(xml).find('option').each(function(){
                        var kitID = $(this).children('kitID').text();

                        if ( kitID != '' ) { inMKM = 1; }
                    })
                }
            });
            $('#kitTable').show();
            if ( inMKM == 0 ) { $('#kitTable > tbody:last').append('<tr style="background-color:green;color:white"><td>'+ kit +'</td><td></td></tr>'); } 
            else { $('#kitTable > tbody:last').append('<tr style="background-color:red;color:white"><td>'+ kit +'</td><td>deleted from MKM</td></tr>'); }
            cntUpdate();
            $('#kitID').val('');
            //$('#cmdKit').hide();
            $('#kitID').focus();
        } else {
            $('#kitRackTable').show();
            $.ajax({
                url:"kitSystem.asp?Kit="+kit+"&rack="+rack+"&uT=10"
            });
            $.ajax({
                type:"post",
                url:"kitSystem.asp?Rack="+rack+"&Kit="+kit+"&uT=9",
                dataType:"xml",
                async:false,
                success: function(xml){
                    $(xml).find('option').each(function(){
                        var kitNm = $(this).children('kit').text();
                        var kitStat = $(this).children('stat').text();

                        if ( kitStat == 'RED' ){
                            $('#kitRackTable > tbody:last').append('<tr style="background-color:red;color:white"><td>'+ kitNm +'</td><td>'+ kitStat +'</td><td><input id="cmdPlus" value="+" type="button" /><input id="cmdMinus" value="-" type="button" /></td></tr>');
                        } else {
                            $('#kitRackTable > tbody:last').append('<tr style="background-color:green;color:white"><td>'+ kitNm +'</td><td>'+ kitStat +'</td><td><input id="cmdMinus" value="-" type="button" /></td></tr>');
                        }
                        cntUpdate();
                        $('#kitID').val('');
                        //$('#cmdKit').hide();
                        $('#kitID').focus();
                    });
                }
            });
        }
    }
}

0 个答案:

没有答案