Add text before answer option of single question

From Catglobe Wiki
Revision as of 11:19, 14 April 2009 by Catglobe (talk | contribs) (New page: == 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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

SingleAddtext.jpg

I want to add an text before answer option like this image

SingleAddtext2.jpg

Solution

Find the answer option in single question , and add new text before it .

Code

 1 quest.insertTextBefore = function(valueOfAnswerOption, text)
 2 {
 3 	var inp = $(".option_table").find("input[value='"+valueOfAnswerOption+"']");
 4 	if(inp.length <= 0)
 5 		return;
 6 	if(this.autoarrangeansweroptions != false && cols > 1)
 7 		$("<tr><td class=\"answer_option_cell\" colspan=\"3\">"+text+"</td></tr>").insertBefore($(inp.parent().parent()));
 8 	else
 9 		$("<tr><td class=\"answer_option_cell\">"+text+"</td></tr>").insertBefore($(inp.parent().parent().parent().parent().parent().parent()));
10 }
11 
12 quest.onInit = function()
13 {
14 	this.insertTextBefore(8, "hello there!!");
15          	this.insertTextBefore(5, "hello there 2!!");
16 }