How do I create a section of text that respondents can edit? I want to show a written passage that’s several paragraphs long and give respondents the opportunity to edit only the first paragraph.
Hello
Add a ‘Text Entry’ question to your survey. Update the header to include an instruction for the customer, such as: “Please edit Paragraph 1 only”.
Next, insert your paragraphs into the text entry box.
Then, add the following JavaScript, replacing the placeholder text ‘Paragraph’ with the actual content of the respective paragraph wherever it appears.
Qualtrics.SurveyEngine.addOnload(function() {
// Get the text entry box
var textBox = jQuery("#" + this.getQuestionContainer().id + " .InputText");
// Pre-fill the text box with the passage
var prefilledText = "Paragraph 1: Paragraph 1 content.\n\n" +
"Paragraph 2: Paragraph 2 content.\n\n" +
"Paragraph 3: Paragraph 3 content.";
textBox.val(prefilledText);
// Disable editing for all text except the first paragraph
textBox.on("input", function() {
var currentText = textBox.val();
var paragraphs = currentText.split("\n\n");
// Keep only the first paragraph editable
if (paragraphs.length > 1) {
paragraphs1] = "Paragraph 2: Paragraph 2 content.";
}
if (paragraphs.length > 2) {
paragraphs 2] = "Paragraph 3: Paragraph 3 content..";
}
// Reassemble the text and update the text box
textBox.val(paragraphs.join("\n\n"));
});
});
I found this code online and tested it in my lisence, its working as expected.
Thank you,
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.