Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Add text before answer option of single question: Difference between revisions

From Catglobe Wiki
Cg van (talk | contribs)
uestion to Question
Line 24: Line 24:
|}
|}


== Solution ==
== Solution ==
 
*Add a Single question to Questionaire editor
Find the index of the row in single question , and add new text before it .
*Go to menu Properties -> Question scripts -> Java script tab -> Input script


== Code  ==
== Code  ==
Line 62: Line 62:
}
}
</source>
</source>
==Source==
Questionnaire Resource Id on cg site: 159730
Question: Q_OS_Single_AddTextBeforeAO

Revision as of 07:46, 3 February 2012

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

  • Add a Single question to Questionaire editor
  • Go to menu Properties -> Question scripts -> Java script tab -> Input script

Code

quest.insertTextBefore = function(aoIndex, text)
{
	var that = this;
	$(".option_row").each(
		function(i)
		{
			if (i == aoIndex)
			{
				var tr = $("<tr>").addClass("customized_text")
						.append($("<td>").text(text).attr("colSpan",that.cols)); 
				$(this).before(tr);
			}
		}
	);

}

quest.onInit = function()
{
   var text = "My Text";
	this.insertTextBefore(2, text);
}

Question stylesheet

.customized_text
{
   background-color:white;
}

Source

Questionnaire Resource Id on cg site: 159730 Question: Q_OS_Single_AddTextBeforeAO