Cart Buy Licenses Contact Integrate into App Docs Support Login/Register
v 1.8.52
v 1.8.52
Overview Examples Docs Source Download

onGetQuestionTitle event

Use this event to change the question title in code. If you want to remove question numbering then set showQuestionNumbers to "off".
sender - the survey object that fires the event.
options.title - a calculated question title, based on question title, name.
options.question - a question object.


onGetQuestionTitle event calls every time the survey needs to render the title. You may use it to modify the question title before rendering. The example below shows how to create custom question numbering using this event. By default you may numbering question though all survey or by page, starting from a number or char based on survey.questionStartIndex property. Let's say you want to have the following numbering in question: .. For example the third question on the second page will be as: 2.c.. Here is the code you need to write:

// Turn off the default showQuestionNumbers;
survey.showQuestionNumbers = "off";
// Use the event to generate the question number as {pageNo}.{questionNoOnPage}
// Where questionNoOnPage starts with 'a'
survey.onGetQuestionTitle.add(function(sender, options){
    var index = getQuestionIndexOnPage(options.question, true);
    if(index < 0) return;
    questionChar = String.fromCharCode("a".charCodeAt(0) + index);
    options.title = ( + 1) + '.' + questionChar + ". " + options.title;
//get question index on its page, set the second parameter to true to get the index from visible questions only
function getQuestionIndexOnPage(question, onlyVisible) {
    if(!onlyVisible) return;
    var list = [];
    //get only visbile questions, true);
    return list.indexOf(question);

Here is the full example of this functionality.

Implemented in:
See also:
showQuestionNumbers * , requiredText

Show More