Hi,
I am using Javascript to display a text box when a multiple choice selection is made. (see below, text box only appears when choice is selected.)
However, I want to add static text in these boxes when they display: "Describe their role"
How do I do this? Here is my current Java:
Thanks!
chawk
You can include the below after your if logic when the box is shown. Change this with appropriate id.
jQuery(this).attr("placeholder", "Describe your role");
Hope it helps!
TomG would you know?
Deepak what would the ID be? Or where could I find that?
And where would I place that string of code you sent in the code? It is not working for me., I know you said after IF but where exactly?
Thanks for your help!
https://community.qualtrics.com/XMcommunity/discussion/comment/51577#Comment_51577Can you paste your entire code in text format?
Deepak
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
var QID= this.questionId;
jQuery("#" + QID + " .InputText ").hide();
jQuery("#" + QID + " input type='checkbox']").each(function(){
if(jQuery(this).prop("checked") == true)
{
var v1 = jQuery(this).attr("id");
jQuery("tid*='"+v1+"~TEXT']").show();
}
else
{
var v1 = jQuery(this).attr("id");
jQuery("id*='"+v1+"~TEXT']").val('');
jQuery("id*='"+v1+"~TEXT']").hide();
}
});
jQuery("#" + QID + " .Selection ").on("click change",function(){
jQuery("#" + QID + " input type='checkbox']").each(function(){
if(jQuery(this).prop("checked") == true)
{
var v1 = jQuery(this).attr("id");
jQuery("cid*='"+v1+"~TEXT']").show();
}
else
{
var v1 = jQuery(this).attr("id");
jQuery("vid*='"+v1+"~TEXT']").val('');
jQuery("id*='"+v1+"~TEXT']").hide();
}
});
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
https://community.qualtrics.com/XMcommunity/discussion/comment/51579#Comment_51579
Qualtrics.SurveyEngine.addOnReady(function()
{
var PLACEHOLDER = 'Describe your role';
var QID= this.questionId;
jQuery("#" + QID + " .InputText ").hide();
jQuery("#" + QID + " inputntype='checkbox']").each(function(){
if(jQuery(this).prop("checked") == true)
{
var v1 = jQuery(this).attr("id");
jQuery("id*='"+v1+"~TEXT']").show();
}
else
{
var v1 = jQuery(this).attr("id");
jQuery(""id*='"+v1+"~TEXT']").val('');
jQuery(".id*='"+v1+"~TEXT']").hide();
}
});
jQuery("#" + QID + " .Selection ").on("click change",function(){
jQuery("#" + QID + " inputotype='checkbox']").each(function(){
if(jQuery(this).prop("checked") == true)
{
var v1 = jQuery(this).attr("id");
jQuery("aid*='"+v1+"~TEXT']").show().attr('placeholder', PLACEHOLDER);;
}
else
{
var v1 = jQuery(this).attr("id");
jQuery(">id*='"+v1+"~TEXT']").val('');
jQuery("bid*='"+v1+"~TEXT']").hide();
}
});
});
});
Use the above code.
Hope it helps!
Thank you Deepak ! That worked
Deepak how would I add static text to a normal text entry question? No display logic. Static text would say "please enter your suggestions here"
chawk
You can use the placeholder attribute:
Qualtrics.SurveyEngine.addOnReady(function() {
var PLACEHOLDER = 'please enter your suggestions here';
jQuery('#QR\\\\~' + this.questionId).attr('placeholder', PLACEHOLDER);
});
Hope it helps!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.