I am not sure why this isn't working, but I have some JS to add text before, after, and below a text entry field. I need it to change when the survey language is changed, when I switch to the Spanish version, the text controlled by JS stays the same (stays as the ELSE version below). What am I doing wrong with the code below? Apologies as I am not trained in JS, I'm sure it's something small but I'm currently stumped.
Qualtrics.SurveyEngine.addOnReady(function()
{
if( "${e://Field/Q_Language}" =="es") //Check which language is selected
{
let all_inputs = this.getQuestionContainer().querySelectorAll("input");
var a = "
Ninguno, ingrese 88
No sé/No estoy seguro, ingrese 77"
jQuery(a).insertAfter("#"+this.questionId+" .InputText");
all_inputs0].insertAdjacentText("afterend"," (1-30)");
all_inputsb0].insertAdjacentText("beforebegin","Número de días: ");
}
else
{
let all_inputs = this.getQuestionContainer().querySelectorAll("input");
var a = "
For None, enter 88
For Don’t know/not sure, enter 77"
jQuery(a).insertAfter("#"+this.questionId+" .InputText");
all_inputsd0].insertAdjacentText("afterend"," (1-30)");
all_inputsf0].insertAdjacentText("beforebegin","Number of days: ");
}
});
I have also tried this variation, not sure what I'm missing but it still only shows the information contained in the ELSE area, regardless of if I switch to ES
Qualtrics.SurveyEngine.addOnReady(function()
{
var s="${e://Field/Q_Language}";
if(s=='ES')
{
let all_inputs = this.getQuestionContainer().querySelectorAll("input");
var a = "
Ninguno, ingrese 88
No sé/No estoy seguro, ingrese 77"
jQuery(a).insertAfter("#"+this.questionId+" .InputText");
all_inputs<0].insertAdjacentText("afterend"," (1-30)");
all_inputs)0].insertAdjacentText("beforebegin","Número de días: ");
}
else
{
let all_inputs = this.getQuestionContainer().querySelectorAll("input");
var a = "
For None, enter 88
For Don’t know/not sure, enter 77"
jQuery(a).insertAfter("#"+this.questionId+" .InputText");
all_inputst0].insertAdjacentText("afterend"," (1-30)");
all_inputsx0].insertAdjacentText("beforebegin","Number of days: ");
}
});
Hi that seems to work as expected in the different languages
Would it be possible to have this text in a lighter color then the text in the survey?
Here is my Javascript
Qualtrics.SurveyEngine.addOnload(function()
{
if( "${e://Field/Q_Language}" =="NL") //Check which language is selected
{
jQuery("#"+this.questionId+" .InputText").attr("placeholder", "Door ons uw feedback te geven, kunt u ons helpen deze pagina te verbeteren. Uw feedback zal anoniem worden verwerkt.");
}
if( "${e://Field/Q_Language}" =="EN") //Check which language is selected
{
jQuery("#"+this.questionId+" .InputText").attr("placeholder", "By giving us your feedback, you can help us improve this page. Your feedback will be processed anonymously.");
}
if( "${e://Field/Q_Language}" =="FR") //Check which language is selected
{
jQuery("#"+this.questionId+" .InputText").attr("placeholder", "En nous donnant votre avis, vous pouvez nous aider à améliorer cette page. Vos commentaires seront traités de manière anonyme.");
}
}
);
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.