Is Display Logic compatible with Javascript for a Fake Next button? | XM Community
Skip to main content

I have a block in a survey where I use fake next button Javascript to validate numeric entries in different fields before the respondent can move to the next page. (The beginning and end of the code is below.)
It's worked fine in all survey cycles to date. For the next survey cycle I'm trying to add a question to the block that is part of the validation but is only displayed under certain conditions. I edited the Javascript to incorporate the validation with the new question before I set up the Display Logic and it worked as expected. But once the Display Logic is added to the new question, the Next button is unresponsive.
I have workarounds that I can pursue, so I'm not looking for someone to provide an extensive programming solution. Mainly, since this is the type of thing unlikely to be documented, I'm just looking for confirmation from someone with programming experience whether or not Display Logic and fake next button Javascript are incompatible when the same question is referenced in both.

image.png

You have a syntax error...you can only add an else to an if.


Thanks for your reply, @TomG. That's not the full code; I deleted hundreds of lines in between just for display purposes. The Javascript works as expected before I add the Display Logic to the next question. It seems that the addition of Display Logic interferes with the Javascript.


https://www.qualtrics.com/community/discussion/comment/27051#Comment_27051Your fake next button should work if you've set it up correctly. Is the JS above attached to 1 question on the page with no display logic on the question? Are there any other scripts on the page?
BTW, I don't think you don't need to hide the fake next button or return.


Thanks Tom. The JS is attached to 10 questions on the same page, and Display Logic is used on 3 of the 10 questions. No other scripts on the page.
Just to see if I could narrow down the problem I created a simplified copy of the page, with JS attached to just four questions. The JS worked before I added the Display Logic to three questions; it no longer worked after.


I think it doesn't matter if you have JS with fakebutton and display logic for few questions. I checked your scenario where I had added the JS at 1st question which have fakebutton and added display logic for other 3 questions. It worked for me. In your case if your questions which have display logic and you are using the id of that question in JS and those questions are not appearing then it might be giving an error. Not sure if I'm following it correctly in your scenario. But with fakebutton in JS and display logic works fine.


Thanks SurajK. My scenario is a little different from what you described, but I think I've now found a different way to set up this sequence of questions that won't require Javascript.
Also appreciate the time, TomG.


Leave a Reply