I am going crazy trying to figure out why my code won’t work. I have created a fake next button in HTML and styled in through the Look and Feel CSS menu. It is appearing on my screen as expected but when I click it nothing happens.
<button id="fakeNext" > → </button>
This is the code I have associated with the fake button
Qualtrics.SurveyEngine.addOnReady(function()
{
document.querySelector("#Buttons").insert(document.querySelector('#fakeNext'));
this.hideNextButton();
var $jq = jQuery.noConflict();
//Place your JavaScript here to run when the page is fully displayed*/
//define this
var qobj = this;
//get set to throw error messages on value
var q = jQuery("#"+this.questionId);
var ve = q.find(".ValidationError").first();
jQuery('#fakeNext').click(function(){
//pull in the values form the table and which options were selected in previous question
var youthEng = qobj.getChoiceValue(1,1);
var youthSpan = qobj.getChoiceValue(2,1);
var youthHmg = qobj.getChoiceValue(3,1);
var youthOth = qobj.getChoiceValue(4,1);
var adultEng = qobj.getChoiceValue(1,2);
var adultSpan = qobj.getChoiceValue(2,2);
var adultHmg = qobj.getChoiceValue(3,2);
var adultOth = qobj.getChoiceValue(4,2);
var pq = '${q://QID5/SelectedChoicesRecode}';
console.log(youthEng, youthSpan, youthHmg, youthOth, adultEng, adultSpan, adultHmg, adultOth, pq);
ve.hide();
//if youth is selected make sure at least one langauge has an entry greater than 1
if( (pq.includes(2)) && (youthEng < 1 || youthEng == 'false') && (youthSpan < 1 || youthSpan =='false') && (youthHmg < 1 || youthHmg =='false') && (youthOth < 1 || youthOth =='false')) {
document.body.scrollTop = document.documentElement.scrollTop = 0;
ve.html("You must put a number in the youth column or change the previous page to show you do not have youth openings.");
ve.show();
return false;
}
//if adult is selected make sure at least one language has an entry greater than 1
else if( (pq.includes(1)) && (adultEng < 1 || adultEng == 'false') && (adultSpan < 1 || adultSpan =='false') && (adultHmg < 1 || adultHmg =='false') && (adultOth < 1 || adultOth =='false')) {
document.body.scrollTop = document.documentElement.scrollTop = 0;
ve.html("You must put a number in the youth column or change the previous page to show you do not have youth openings.");
ve.show();
return false;
}
//if all is okay press the next button
else{
//press the next button
jQuery('#NextButton').click();
}
});
});
What is driving me crazy is that everything is working just fine when I change the button reference in my click function to ‘#NextButton’ but with the existing code when I click the fakeNext button nothing happens. Any help is greatly appreciated!