javascript开关语句未触发

javascript开关语句未触发,javascript,Javascript,我在ASP.NET C#web应用程序上的javascript中有一个switch语句。我正在用FireBug调试它,它正在出错:它一到达开关就立即存在 代码如下: $(function() { $('#received_dateTextbox').mask("99/99/99"); $('#report_dateTextBox').mask("99/99/99"); $('#occurrence_dateTextBox').mask("99/99/99");

我在ASP.NET C#web应用程序上的javascript中有一个
switch
语句。我正在用FireBug调试它,它正在出错:它一到达
开关
就立即存在

代码如下:

$(function() {

    $('#received_dateTextbox').mask("99/99/99");
    $('#report_dateTextBox').mask("99/99/99");
    $('#occurrence_dateTextBox').mask("99/99/99");

    //var checkValues='';

    $('table input:checkbox').click(function() {

        if ($(this).prop('checked')) {
            var checkText = $(this).next('a').text();
            var hrefValue = $(this).next('a').attr('href');
            var trimIndex = hrefValue.lastIndexOf('\\') + 1;
            var checkValue =  hrefValue.substr(trimIndex, hrefValue.indexOf("')",trimIndex)-trimIndex);

            //checkValues+=checkValue+";";

            switch(checkValue)
            {
                //preanalytical other
                case "21": 
                    var userInput = prompt("Other:", "Other:");
                    $(this).next('a').html('Other:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical other
                case "53": 
                    var userInput = prompt("Other:", "Other:");
                    $(this).next('a').html('Other:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //postanalytical other
                case "89": 
                    var userInput = prompt("Other:", "Other:");
                    $(this).next('a').html('Other:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //other other
                case "95": 
                    var userInput = prompt("Other:", "Other:");
                    $(this).next('a').html('Other:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical liquid handler instrument failure
                case "40":
                    var userInput = prompt("Liquid Handler#:", "Liquid Handler#:");
                    $(this).next('a').html('Liquid Handler#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical olympus instrument failure
                case "41":                   
                    var userInput = prompt("Olympus#:", "Olympus#:");
                    $(this).next('a').html('Olympus#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical lcms instrument failure
                case "42":
                    var userInput = prompt("LC-MS/MS#:", "LC-MS/MS#:");
                    $(this).next('a').html('LC-MS/MS#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical liquid handler delay prod
                case "49":
                    var userInput = prompt("Liquid Handler#:", "Liquid Handler#:");
                    $(this).next('a').html('Liquid Handler#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical olympus delay prod
                case "50":
                     var userInput = prompt("Olympus#:", "Olympus#:");
                    $(this).next('a').html('Olympus#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //analytical lcms delay prod
                case "51":
                    var userInput = prompt("LC-MS/MS#:", "LC-MS/MS#:");
                    $(this).next('a').html('LC-MS/MS#:' + '<font color="red">' + userInput + '</font>');
                    checkValues+=checkValue+":"+userInput;
                break;

                //wrong practice code
                case "63":
                    if (confirm("Do you want to check Report Sent to Wrong Location/Physician?"))
                    { var elNode = document.getElementById("TreeView1n82CheckBox");
                        $(elNode).prop("checked", true);
                     }
                    else
                    { var elNode = document.getElementById("TreeView1n81CheckBox");
                        $(elNode).prop("checked", false);
                    }

                break;  

                default: 
                    alert('no match');                
            }
        }
    });
    //document.getElementById('HiddenField1').value = checkValues;
});
$(函数(){
$(“#已收到的日期文本框”).mask(“99/99/99”);
$('#report_dateTextBox')。掩码(“99/99/99”);
$(“#事件"日期文本框”).mask(“99/99/99”);
//var校验值=“”;
$(“表输入:复选框”)。单击(函数(){
if($(this.prop('checked')){
var checkText=$(this.next('a').text();
var hrefValue=$(this.next('a').attr('href');
var trimIndex=hrefValue.lastIndexOf('\\')+1;
var checkValue=hrefValue.substr(trimfindex,hrefValue.indexOf(“'),trimfindex)-trimfindex);
//checkValues+=checkValues+“;”;
开关(校验值)
{
//分析前其他
案例“21”:
var userInput=prompt(“其他:”,“其他:”);
$(this).next('a').html('Other:'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//分析性其他
案例“53”:
var userInput=prompt(“其他:”,“其他:”);
$(this).next('a').html('Other:'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//分析后其他
案例“89”:
var userInput=prompt(“其他:”,“其他:”);
$(this).next('a').html('Other:'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//其他
案例“95”:
var userInput=prompt(“其他:”,“其他:”);
$(this).next('a').html('Other:'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//分析液体处理器仪器故障
案例“40”:
var userInput=prompt(“液体处理程序:”,“液体处理程序:”;
$(this).next('a').html('Liquid Handler#):'+''+userInput+'';
checkValues+=checkValues+“:”+用户输入;
打破
//奥林巴斯分析仪器故障
案例“41”:
var userInput=prompt(“奥林巴斯:”,“奥林巴斯:”;
$(this).next('a').html('Olympus#::'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//分析lcms仪器故障
案例“42”:
var userInput=prompt(“LC-MS/MS:”,“LC-MS/MS:”;
$(this).next('a').html('LC-MS/MS#:'+''+userInput++');
checkValues+=checkValues+“:”+用户输入;
打破
//分析液体处理器延迟探针
案例“49”:
var userInput=prompt(“液体处理程序:”,“液体处理程序:”;
$(this).next('a').html('Liquid Handler#):'+''+userInput+'';
checkValues+=checkValues+“:”+用户输入;
打破
//解析奥林巴斯延迟产品
案例“50”:
var userInput=prompt(“奥林巴斯:”,“奥林巴斯:”;
$(this).next('a').html('Olympus#::'+''+userInput+'');
checkValues+=checkValues+“:”+用户输入;
打破
//解析式lcms延迟产品
案例“51”:
var userInput=prompt(“LC-MS/MS:”,“LC-MS/MS:”;
$(this).next('a').html('LC-MS/MS#:'+''+userInput++');
checkValues+=checkValues+“:”+用户输入;
打破
//错误的执业守则
案例“63”:
如果(确认(“您想检查发送到错误位置/医生的报告吗?”)
{var elNode=document.getElementById(“TreeView1n82CheckBox”);
$(elNode).prop(“选中”,为真);
}
其他的
{var elNode=document.getElementById(“TreeView1n81CheckBox”);
$(elNode).prop(“选中”,false);
}
打破
违约:
警报(“不匹配”);
}
}
});
//document.getElementById('HiddenField1')。value=checkValues;
});
调试器告诉我,
checkValue
肯定有一个值


我做错了什么?

不确定确切的行为,但如果
checkValues
为null或未定义,我希望它在该行中断。

也许
checkValues
中有一个空间需要修剪?在您的
默认值中
-像这样显示
检查值
的值,这样应该更清楚:

default: 
     alert('no match for "' + checkValue + '"');

checkValue
可以存储为数字,而不是像所有“case”检查那样存储为字符串

检查
case parseInt(“95”):…
是否有效

此外,如果向数字中添加字符,请检查案例是否开始工作,然后检查:

开关(校验值+A')


然后
案例“53A”:。。。。中断

是否没有错误?您是否真的在实际代码中结束了switch语句?但它是否具有您所指定的值之一?如果您添加
默认值:警报(“不匹配”)到你的开关,警报显示了吗?@marc是的,它有我输入的值for@pimvdb是的,我发布了我的代码的其余部分如果警报出现,那么您的
案例
值都不匹配;我是雷莫