| ").attr("align","center")
.append($("<input type='radio' id='" + id + "' name='" + this.shortLabel + "' value='" + ao + "' onclick='javascript:optclickcustom(\"" + name + "\", " + ao + ", " + false + ");'" + checked + ">"));
var aotext = $("
|
").attr("align","left")
.append($("<a href='javascript:optclickcustom(\"" + name + "\", " + ao + ", " + true + ");'>").addClass("option_link").text(this.aoTexts[i])); tr.append(radiob).append(aotext);
return tr; }
Single.prototype.validate = function() { var a = true; if ($("input:hidden[name='" + this.label + "']").val() == "") { var a = false; showError(quest.requiredtext.replace(".",": ") + this.text); } return a; }
function showError(e) { ErrorMessages.getInstance().showErrorMessage(e); }
function optclickcustom(name, value, bool) { var id = name + "_" + value; $("input:hidden[name='" + name + "']").val(value); if (bool) $("input[id='" + id + "']").attr("checked", true); }
</source>
- The second script part needs to be modified by the questionnaire creator to fit the real questionnaire. It must be added to the page question's javascript.
<source lang="javascript"> var qH1; var qH2; var qH3;
quest.onInit = function() {
//------CONFIGURATION PART---------------
var q1 = {
'label': 'Q1',//question's label
'text':'Q1',//question's text
'aoTexts': ['AO1', 'AO2'],//answer options' texts
'aoValues': [1,2],//answer options' values
'selectedValue':"Template:Q1.value"//previously selected value, please remember to use EXACT texts, do not use loops to generate values
};
var q2 = {
'label': 'Q2',
'text':'Q2',
'aoTexts': ['AO1', 'AO2', 'AO3'],
'aoValues': [1,2,3],
'selectedValue':"Template:Q2.value"
};
var q3 = {
'label': 'Q3',
'text':'Q3',
'aoTexts': ['AO1', 'AO2', 'AO3', 'AO4'],
'aoValues': [1,2,3,4],
'selectedValue':"Template:Q3.value"
};
//create object to get HTML qH1 = new Single(q1); qH2 = new Single(q2); qH3 = new Single(q3);
var table = $("
| ").append(qH1.getHTML()));
table.append(tr);
var tr = $("
|
| ").append(qH2.getHTML()));
table.append(tr);
var tr = $("
|
| ").append(qH3.getHTML()));
table.append(tr);
$("#page_question_text").append(table); $(".question_outer").width("100%"); }
//Check if all questions have values questioncheck = function() { ErrorMessages.getInstance().clearErrorMessages(); return qH1.validate() && qH2.validate() && qH3.validate(); }
</source>
|
|