程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> js中switch case循環一例

js中switch case循環一例

編輯:關於JSP

switch (objNameType) {
        case 'PD':
            valueUD = obj.id;
            id = objName;
            var loadVUD = UserData.load(exam, id);
            if (loadVUD == null || loadVUD == undefined || loadVUD == '') {
                var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                qNoTotalD[qIdNoStr[tmpTGId]]++;
            }
            break;
  case 'DANX':
            valueUD = obj.id;
   var objName = obj.name;
   var objNameTop = objName.substr(0,objName.indexOf('_'));
            id = objName;
            var loadVUD = UserData.load(exam, id);
            if (loadVUD == null || loadVUD == undefined || loadVUD == '') {
                var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                qNoTotalD[qIdNoStr[tmpTGId]]++;
            }
            break;
  case 'PP':
            valueUD = obj.id;
   var objName = obj.name;
   var objNameTop = objName.substr(0,objName.indexOf('_'));
            id = objName;
            var loadVUD = UserData.load(exam, id);
            if (loadVUD == null || loadVUD == undefined || loadVUD == '') {
                var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                qNoTotalD[qIdNoStr[tmpTGId]]++;
            }
            break;
        case 'text':
            valueUD = obj.value;
            id = "text_" + obj.id;
            var loadVUD = UserData.load(exam, id);
            if (loadVUD == null) {
                if (valueUD == null || valueUD == '') {
                    return;
                }
                else {
                    var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                    qNoTotalD[qIdNoStr[tmpTGId]]++;
                }
            }
            else {
                if (valueUD == null || valueUD == '') {
                    UserData.remove(exam, id);
                    examAnswerKeyStr = removeStrWithcomma(examAnswerKeyStr, id);
                    UserData.save(examinfo, "examAnswerKeyStr", examAnswerKeyStr, 1);
                    var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                    qNoTotalD[qIdNoStr[tmpTGId]]--;
                    return;
                }
            }
            break;
        case 'checkbox':
            id = "checkbox_" + obj.id.substr(0, obj.id.lastIndexOf('_'));
            var key = obj.id.substr(0, obj.id.lastIndexOf('_'));
            key = "checkbox_" + key;
            valueUD = UserData.load(exam, key);
            var flag = obj.checked;
            if (valueUD == null) {
                if (flag) {
                    id = key;
                    valueUD = obj.id;
                    var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                    qNoTotalD[qIdNoStr[tmpTGId]]++;
                }
            }
            else {
                if (flag) {
                    if (valueUD.indexOf(obj.id) == -1) {
                        valueUD += "," + obj.id
                    }
                }
                else {
                    if (valueUD.indexOf(obj.id) != -1) {
                        if (valueUD.indexOf(',' + obj.id) != -1) {
                            valueUD = valueUD.replace(',' + obj.id, '');
                        }
                        else
                            if (valueUD.indexOf(obj.id + ',') != -1) {
                                valueUD = valueUD.replace(obj.id + ',', '');
                            }
                            else {
                                UserData.remove(exam, key);
                                examAnswerKeyStr = removeStrWithcomma(examAnswerKeyStr, key);
                                UserData.save(examinfo, "examAnswerKeyStr", examAnswerKeyStr, 1);
                                var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                                qNoTotalD[qIdNoStr[tmpTGId]]--;
                                return;
                            }
                    }
                }
            }
            break;
           
        case 'textarea':
            valueUD = obj.value;
            id = "textarea_" + obj.id;
            var loadVUD = UserData.load(exam, id);
            if (loadVUD == null) {
                if (valueUD == null || valueUD == '') {
                    return;
                }
                else {
                    var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                    qNoTotalD[qIdNoStr[tmpTGId]]++;
                }
            }
            else {
                if (valueUD == null || valueUD == '') {
                    UserData.remove(exam, id);
                    examAnswerKeyStr = removeStrWithcomma(examAnswerKeyStr, id);
                    UserData.save(examinfo, "examAnswerKeyStr", examAnswerKeyStr, 1);
                    var tmpTGId = obj.id.substr(0, obj.id.indexOf('_'));
                    qNoTotalD[qIdNoStr[tmpTGId]]--;
                    return;
                }
            }
            break;
        default:
            return;    }
本文出自 “一燈” 博客

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved