Difference between revisions of "Questionnaire - Javascript Fun Tips"
Line 14: | Line 14: | ||
==== quest ==== | ==== quest ==== | ||
− | There are | + | There are several important properties in quest object: |
− | quest.setQuestions(Array subQuestions) | + | *quest.questions: array of sub questions |
− | + | *quest.options: array of answer options | |
− | quest.setOptions(Array options) | + | *quest.setQuestions(Array subQuestions): assign an array of question objects to the sub question list of the current question |
− | + | *quest.setOptions(Array options): assign an array of options to the answer option list of the current question | |
− | quest.setAnswer(string value) | + | *quest.setAnswer(string value): assign a value to the question |
− | + | *ques.getHTML(): returns the HTML which will be rendered to display the question | |
− | ques.getHTML | + | *quest.onInit(): called right after loading the question |
− | |||
− | quest.onInit | ||
− | |||
− | |||
− | |||
− | |||
==== questioncheck ==== | ==== questioncheck ==== |
Revision as of 11:31, 18 December 2008
Basic Hints
Questionnaire viewer is implemented in a way that you can add javascript to manipulate the way your questions are displayed.
jQuery is already included in the viewer, thanks to what javascript has even more powerful effect! (read more about jquery here: http://jquery.com/)
Javascript is a property on both question and questionnaire levels, which means that you can add javascript for each question or for the whole questionnaire.
The most important features are:
- quest: the current question's object
- questioncheck: the function that will be called before going Next
quest
There are several important properties in quest object:
- quest.questions: array of sub questions
- quest.options: array of answer options
- quest.setQuestions(Array subQuestions): assign an array of question objects to the sub question list of the current question
- quest.setOptions(Array options): assign an array of options to the answer option list of the current question
- quest.setAnswer(string value): assign a value to the question
- ques.getHTML(): returns the HTML which will be rendered to display the question
- quest.onInit(): called right after loading the question
questioncheck
ErrorMessages.getInstance().showErrorMessage(msg);
ErrorMessages.getInstance().clearErrorMessages();
Examples
Hide sub question text column in a grid question
Show a text grid question and a single question in the same page
Add an extra column before an answer option column in single grid question
Change stylesheet of an answer option column in a single grid question