Add text before answer option of single question
Challenge
In order to add text before answer option of single question
As a questionnaire creator
I want to add text before answer option of single question
Example
I have a single question.
<img src="/images/a/a3/OneColumnBefore.JPG" _fck_mw_filename="OneColumnBefore.JPG" alt="" /> | <img src="/images/0/08/MultiColumnBefore.JPG" _fck_mw_filename="MultiColumnBefore.JPG" alt="" /> |
I want to add an text before answer option like this image
<img src="/images/2/2f/OneColumnAfter.jpg" _fck_mw_filename="OneColumnAfter.jpg" alt="" /> | <img src="/images/6/69/MultiColumnAfter.jpg" _fck_mw_filename="MultiColumnAfter.jpg" alt="" /> |
Solution
- Add a Single question to Questionaire editor
- Go to menu Properties -> Question scripts -> Java script tab -> Input script
<img src="/images/5/56/AddTextBeforeAOOfSingleQuestion.jpg" _fck_mw_filename="AddTextBeforeAOOfSingleQuestion.jpg" alt="" />
Code
fckLRquest.insertTextBefore = function(aoIndex, text)fckLR{fckLR var that = this;fckLR $(".option_row").each(fckLR function(i)fckLR {fckLR if (i == aoIndex)fckLR {fckLR var tr = $("<tr>").addClass("customized_text")fckLR .append($("<td>").text(text).attr("colSpan",that.cols)); fckLR $(this).before(tr);fckLR }fckLR }fckLR );fckLRfckLR}fckLRfckLRquest.onInit = function()fckLR{fckLR var text = "My Text";fckLR this.insertTextBefore(2, text);fckLR}fckLR
Question stylesheet
fckLR.customized_textfckLR{fckLR background-color:white;fckLR}fckLR
Source
Questionnaire Resource Id on cg site: 159730
Question: Q_OS_Single_AddTextBeforeAO