Difference between revisions of "Reverse the position of the subquestion texts with their textboxes in the text-grid question"
CGHelpdesk (talk | contribs) |
CGHelpdesk (talk | contribs) |
||
Line 3: | Line 3: | ||
This guide will help you reverse the position of the subquestion texts with their textboxes in the text-grid question such as below images: | This guide will help you reverse the position of the subquestion texts with their textboxes in the text-grid question such as below images: | ||
− | Put below javascript code snippet into your text-grid question. The function reverseQuestionTextsWithTextBoxes() requires the textbox width parameter. This function will do the reverse and set the textboxes' width to the specifed width. <source lang="javascript"> | + | Put below javascript code snippet into your text-grid question. |
+ | |||
+ | The function reverseQuestionTextsWithTextBoxes() requires the textbox width parameter. This function will do the reverse and set the textboxes' width to the specifed width. | ||
+ | |||
+ | <br/><source lang="javascript"> | ||
function reverseQuestionTextsWithTextBoxes(textBoxWidth /*number type and required*/) { | function reverseQuestionTextsWithTextBoxes(textBoxWidth /*number type and required*/) { | ||
$('td.grid_subquestion_text').each(function() { | $('td.grid_subquestion_text').each(function() { |
Revision as of 10:41, 14 November 2013
Reverse the position of the subquestion texts with their textboxes in the text-grid question
This guide will help you reverse the position of the subquestion texts with their textboxes in the text-grid question such as below images:
Put below javascript code snippet into your text-grid question.
The function reverseQuestionTextsWithTextBoxes() requires the textbox width parameter. This function will do the reverse and set the textboxes' width to the specifed width.
function reverseQuestionTextsWithTextBoxes(textBoxWidth /*number type and required*/) {
$('td.grid_subquestion_text').each(function() {
$(this).parent().append(this);
$(this).prev()
.removeAttr('width').css({'border-left':'none', 'border-right':'dotted 1px #ccc', 'width': (Number(textBoxWidth) + 10) + 'px' })
.children('input:text').css('width', textBoxWidth + 'px');
});
}
quest.onInit = function() {
reverseQuestionTextsWithTextBoxes(150); // Reverse and set the textbox width to 150px
};