Difference between revisions of "Add text before answer option of single question"
(→Code) |
(→Code) |
||
Line 24: | Line 24: | ||
<source lang="javascript" line="1"> | <source lang="javascript" line="1"> | ||
− | quest.insertTextBefore = function( | + | quest.insertTextBefore = function(rowIndex, text) |
{ | { | ||
$(".option_row").each( | $(".option_row").each( | ||
Line 31: | Line 31: | ||
if (i == aoIndex) | if (i == aoIndex) | ||
{ | { | ||
− | + | var tr = $("<tr>").addClass("customized_text").append($("<td>").text(text)); | |
− | + | $(this).before(tr); | |
} | } | ||
} | } | ||
); | ); | ||
+ | |||
} | } | ||
Line 41: | Line 42: | ||
{ | { | ||
var text = "My Text"; | var text = "My Text"; | ||
− | this.insertTextBefore( | + | this.insertTextBefore(2, text); |
} | } | ||
</source> | </source> |
Revision as of 04:24, 15 April 2009
Contents
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.
I want to add an text before answer option like this image
Solution
Find the answer option in single question , and add new text before it .
Code
1 quest.insertTextBefore = function(rowIndex, text)
2 {
3 $(".option_row").each(
4 function(i)
5 {
6 if (i == aoIndex)
7 {
8 var tr = $("<tr>").addClass("customized_text").append($("<td>").text(text));
9 $(this).before(tr);
10 }
11 }
12 );
13
14 }
15
16 quest.onInit = function()
17 {
18 var text = "My Text";
19 this.insertTextBefore(2, text);
20 }
Question stylesheet
.customized_text
{
background-color:white;
}