This article mainly introduced in JS switch case loop instance code, a friend in need can refer to the
The code is as follows: 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.in Dexof ('_')); 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.in Dexof ('_')); 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); examanswer Keystr = 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.i Ndexof (', ' + obj.id)!=-1) { valueud = Valueud.replace (', ' + obj.id, '); } else if ( Valueud.indexof (obj.id + ', ')!=-1) { valueud = valueud.replace (obj.id + ', ', '); } else {&N Bsp 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); examanswer Keystr = 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; }