📄 jsquestion.php
字号:
<SCRIPT>
function ChangeInterface () {
if (document.addquestion.answeroptions) {
SaveAnswers();
}
document.addquestion.action.value = "interface";
document.addquestion.submit();
}
function PreviewQuestion (sid) {
var cindex = document.questionlist.choosequestion.selectedIndex;
if (cindex >= 0) {
var qid = document.questionlist.choosequestion.options[cindex].value;
if (qid != "pagebreak") {
var qcount = GetQuestionCount(qid);
var previewwin = window.open("../previewquestion.php?sid="+sid+"&qid="+qid+"&qc="+qcount, "preview", "");
previewwin.focus();
}
}
else { alert("%%SelectQuestionPreview%%"); }
}
function GetQuestionCount (qid) {
var qlistsize = document.questionlist.choosequestion.length;
var gqc1 = 1;
var gqc2 = -1;
for (i=0; i<qlistsize; i++) {
gqc2 = (document.questionlist.choosequestion.options[i].value == qid) ? gqc1 : gqc2;
if (document.questionlist.choosequestion.options[i].value != "pagebreak") {
gqc1++;
}
}
return gqc2;
}
function ClearForm (cs) {
if (confirm("%%ClearFormConfirm%%")) {
this.location = "question.php?cs="+cs;
}
}
function ClearField (fieldname) {
var tempfield = eval("document.addquestion."+fieldname);
if (tempfield) {
eval("document.addquestion."+fieldname+".value = \"\";");
}
}
function TypeCheck () {
var cindex = document.addquestion.type.selectedIndex;
var cvalue = document.addquestion.type.options[cindex].value;
var answer = (cq) ? confirm("%%QuestionTypeWarning%%") : true;
if (answer) {
var iindex = document.addquestion.localadvance.selectedIndex;
var ivalue = document.addquestion.localadvance.options[iindex].value;
if (TypeGroup(cvalue) != TypeGroup(ctype)) {
if (document.addquestion.answeroptions) {
SaveAnswers();
}
document.addquestion.submit();
}
ctype = cvalue;
} else {
var typesize = document.addquestion.type.length;
for (i=0; i<typesize; i++) {
var cvalue2 = document.addquestion.type.options[i].value;
if (cvalue2 == ctype) {
document.addquestion.type.selectedIndex = i;
}
}
}
}
function TypeGroup (typevalue) {
var typegroup = 0;
switch (typevalue) {
case "radio": typegroup = 1; break;
case "checkbox": typegroup = 2; break;
case "select": typegroup = 3; break;
case "selectmult": typegroup = 4; break;
case "textfield": typegroup = 5; break;
case "textarea": typegroup = 6; break;
case "htmlcontent": typegroup = 7; break;
}
return typegroup;
}
function AddModifyQuestion (numb) {
var cindex = document.addquestion.type.selectedIndex;
var cvalue = document.addquestion.type.options[cindex].value;
if (cindex >= 0) {
if (cvalue != "textfield" && cvalue != "textarea" && cvalue != "htmlcontent") {
SaveAnswers();
}
if (document.addquestion.answer) {
var answer = document.addquestion.answer.value;
}
if (document.addquestion.mult) {
var mult = document.addquestion.mult.value;
}
var valid = false;
if (document.addquestion.questionasked.value) {
switch (cvalue) {
case "radio":
if (answer) { valid = true; }
break;
case "checkbox":
if (answer) { valid = true; }
break;
case "textfield":
valid = true;
break;
case "textarea":
valid = true;
break;
case "htmlcontent":
if (document.addquestion.instructions &&
document.addquestion.instructions.value != '') {
valid = true;
}
break;
case "select":
if (answer) { valid = true; }
break;
case "selectmult":
if (answer && mult) { valid = true; }
break;
}
if (valid) {
if (numb) {
var mindex = document.questionlist.choosequestion.selectedIndex;
var mvalue = document.questionlist.choosequestion.options[mindex].value;
document.addquestion.modifyid.value = mvalue;
document.addquestion.action.value = "modify";
} else {
document.addquestion.action.value = "add";
}
document.addquestion.submit();
}
else { alert("%%RequiredFieldsWarning%%"); }
}
else { alert("%%QuestionAskedWarning%%"); }
}
else { alert("%%QuestionTypeWarning%%"); }
}
function AddPageBreak () {
document.questionlist.choosequestion.length++;
var cindex = document.questionlist.choosequestion.length-1;
document.questionlist.choosequestion.options[cindex].value = "pagebreak";
document.questionlist.choosequestion.options[cindex].text = "<<----| %%PageBreak%% |---->>";
}
function ChangeQuestion () {
var cindex = document.questionlist.choosequestion.selectedIndex;
if (cindex >= 0) {
var cvalue = document.questionlist.choosequestion.options[cindex].value;
if (cvalue == "pagebreak") {
alert("%%PagebreakEdit%%");
}
else if (cvalue >= 0) {
this.location = "question.php?cs="+cs+"&cq="+cvalue+"&qt="+questions[cindex].Type;
}
}
else { alert("%%SelectQuestionEdit%%"); }
}
function DeleteQuestion () {
var cindex = document.questionlist.choosequestion.selectedIndex;
if (cindex >= 0) {
var cvalue = document.questionlist.choosequestion.options[cindex].value;
if (cvalue == "pagebreak") {
var optionsize = document.questionlist.choosequestion.length;
for (i=1; i<optionsize; i++) {
if (i > cindex) {
var tempvalue = document.questionlist.choosequestion.options[i].value;
document.questionlist.choosequestion.options[i-1].value = tempvalue;
var temptext = document.questionlist.choosequestion.options[i].text;
document.questionlist.choosequestion.options[i-1].text = temptext;
}
}
document.questionlist.choosequestion.length--;
document.questionlist.choosequestion.selectedIndex = -1;
}
else if (cindex >= 0 && confirm("%%QuestionDeleteWarning%%")) {
var cvalue = document.questionlist.choosequestion.options[cindex].value;
document.questionlist.action.value = "delete";
document.questionlist.deleteid.value = cvalue;
document.questionlist.submit();
}
}
else { alert("%%SelectQuestionDelete%%"); }
}
function MoveUp () {
var cindex = document.questionlist.choosequestion.selectedIndex;
if (cindex >= 0) {
if (cindex != 0) {
var questiontemp = document.questionlist.choosequestion.options[cindex].text;
var questiontemp2 = document.questionlist.choosequestion.options[cindex].value;
document.questionlist.choosequestion.options[cindex].text = document.questionlist.choosequestion.options[cindex-1].text;
document.questionlist.choosequestion.options[cindex].value = document.questionlist.choosequestion.options[cindex-1].value;
document.questionlist.choosequestion.options[cindex-1].text = questiontemp;
document.questionlist.choosequestion.options[cindex-1].value = questiontemp2;
document.questionlist.choosequestion.selectedIndex = cindex-1;
tempquestionobj = questions[cindex];
questions[cindex] = questions[cindex-1];
questions[cindex-1] = tempquestionobj;
}
}
else { alert("%%SelectQuestionMove%%"); }
}
function MoveDown () {
var cindex = document.questionlist.choosequestion.selectedIndex;
if (cindex >= 0) {
if (cindex < document.questionlist.choosequestion.length-1) {
var questiontemp = document.questionlist.choosequestion.options[cindex].text;
var questiontemp2 = document.questionlist.choosequestion.options[cindex].value;
document.questionlist.choosequestion.options[cindex].text = document.questionlist.choosequestion.options[cindex+1].text;
document.questionlist.choosequestion.options[cindex].value = document.questionlist.choosequestion.options[cindex+1].value;
document.questionlist.choosequestion.options[cindex+1].text = questiontemp;
document.questionlist.choosequestion.options[cindex+1].value = questiontemp2;
document.questionlist.choosequestion.selectedIndex = cindex+1;
tempquestionobj = questions[cindex];
questions[cindex] = questions[cindex+1];
questions[cindex+1] = tempquestionobj;
}
}
else { alert("%%SelectQuestionMove%%"); }
}
function StoreOrder () {
var qsize = document.questionlist.choosequestion.length;
DeletePageBreaks();
if (qsize > 0) {
var listsize = document.questionlist.choosequestion.length;
var sortorder = "";
for (i=0; i<listsize; i++) {
if (i != 0) { sortorder = sortorder + "||"; }
sortorder = sortorder + document.questionlist.choosequestion.options[i].value;
}
document.questionlist.action.value = "store";
document.questionlist.sortorder.value = sortorder;
document.questionlist.submit();
}
else { alert("%%StoreNoQuestions%%"); }
}
function DeletePageBreaks() {
var qsize = document.questionlist.choosequestion.length;
var pagebreak = true;
while (pagebreak) {
var cvalue = document.questionlist.choosequestion.options[0].value;
if (cvalue == "pagebreak") {
for (var j=0; j<document.questionlist.choosequestion.length-1; j++) {
document.questionlist.choosequestion.options[j].value = document.questionlist.choosequestion.options[j+1].value;
document.questionlist.choosequestion.options[j].text = document.questionlist.choosequestion.options[j+1].text;
}
document.questionlist.choosequestion.length--;
} else {
pagebreak = false;
}
}
var qsize = document.questionlist.choosequestion.length;
var pagebreak = true;
for (var i=qsize-1; i>=0; i--) {
if (pagebreak) {
var cvalue = document.questionlist.choosequestion.options[i].value;
if (cvalue == "pagebreak") {
document.questionlist.choosequestion.length--;
} else {
pagebreak = false;
}
}
}
}
function phpQHelp (helpcontent, heading) {
if (helpwin) { helpwin.close(); }
var helpwin = window.open("help.php?loc="+helpcontent+"&hd="+heading, "help", "directories=no,toolbar=no,menubar=no,location=no,resize=yes,status=no,resizable=yes,scrollbars=yes,width=465,height=275");
helpwin.focus();
}
//---------- Answer Wizard Functions Below -----------
function Init () {
var tindex = document.addquestion.type.selectedIndex;
var type = document.addquestion.type.options[tindex].value;
if (type == "textfield" || type == "textarea" || type == "htmlcontent") { return 1; }
var answer = document.addquestion.answer.value;
if (CheckAnswer(answer)) {
answerarray = answer.split("|||");
defaultchecked = false;
for (i=0; i<answerarray.length; i++) {
temparray = answerarray[i].split("||");
if (temparray[2] != "other+") {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -