Hi! I’m not very knowledgeable about Javascript, so I’m looking for some help. I have two scripts I’m trying to combine.
The first image is the script for inserting slashes to make answers appear as dates (00/00/000). It is formatted for a side-by-side survey question.
The second is to hide lines but have an Add button so the respondent can add lines in a Matrix table as needed.
Both of them work fine on their own, but when I try and combine them they don’t both work. I’m not sure if it’s because the first is formatted for Side-by-Side and the second for a Matrix table and there’s something in the code that is specific for those types of tables, or if there is a problem with variable names?
Thanks for any recommendations you can make!
~Rebekah
Here is my attempt at combining the two, but I know it doesn’t work:
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#"+this.questionId+" tr.ChoiceRow:not(:lt(1))").hide();
});
Qualtrics.SurveyEngine.addOnReady(function(){
jQuery("#" + this.questionId + " .InputText").each(function() {
new Cleave(jQuery(this), {
date: true,
delimiter: '/',
datePattern: d'm', 'd', 'Y']
var that=this.questionId;
jQuery("#"+this.questionId+"tr.ChoiceRow:not(:lt(1))").hide();
jQuery("<input type='button' id='add' value='Add Deployment' name='+' />").insertAfter("#"+this.questionId+" tr.ChoiceRow:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.ChoiceRow:visible").length;
jQuery("#"+that+" tr.ChoiceRow:eq("+c+")").show();
});
});
Qualtrics.SurveyEngine.addOnUnload(function(){
/* Place your JavaScript here to run when the page is unloaded */
});