More actions
Line 6: | Line 6: | ||
== Code == | == Code == | ||
<source lang="javascript" line="1" > | <source lang="javascript" line="1" > | ||
quest.onInit = function() | |||
{ | |||
$.each($("input[type='text']"), function() | |||
{ | |||
var inputName = this.name; | |||
var inputValue = this.value; | |||
var answerOptionValue = inputName.slice(inputName.lastIndexOf(".") + 1); | |||
if ($("input[value='" + answerOptionValue + "']").attr("checked")) | |||
$(this).replaceWith("<textarea rows='8' cols='55' name='" + inputName + "'>" + inputValue + "</textarea>"); | |||
else | |||
$(this).replaceWith("<textarea rows='8' cols='55' disabled = 'disabled' name='" + inputName + "'>" + inputValue + "</textarea>"); | |||
}); | |||
} | |||
</source> | </source> |
Revision as of 05:36, 19 October 2009
Challenge
In Single question or Multi Question, a textbox might not enough for respondent to give a long answer.
As a questionnaire creator
I want to convert a textbox into a textarea.
Code
quest.onInit = function()
{
$.each($("input[type='text']"), function()
{
var inputName = this.name;
var inputValue = this.value;
var answerOptionValue = inputName.slice(inputName.lastIndexOf(".") + 1);
if ($("input[value='" + answerOptionValue + "']").attr("checked"))
$(this).replaceWith("<textarea rows='8' cols='55' name='" + inputName + "'>" + inputValue + "</textarea>");
else
$(this).replaceWith("<textarea rows='8' cols='55' disabled = 'disabled' name='" + inputName + "'>" + inputValue + "</textarea>");
});
}