conditional last-block submit button | XM Community
Skip to main content
Solved

conditional last-block submit button

  • July 31, 2020
  • 3 replies
  • 85 views

jpmorgan
Level 2 ●●
Forum|alt.badge.img+6

I'm building a survey that has three separate question blocks and logic to display one, two, or all three of them, depending on embedded data passed in at the beginning. If multiple blocks appear for a respondent, they are always in the same order.
I'm looking for a way to do something like:
IF: this is the last block in the survey that the respondent will see, change the submit button to "Submit".
ELSE: keep it as an arrow.
Any suggestions for how to pull this off? I found a couple of questions about conditional buttons based on question choice, but that seemed too far off the mark.

Thank you!

Best answer by rondev

We need to change the next button text using java script.
Apply if logic on the embedded data, and based on the value, change the button text using below code:
jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});

3 replies

jpmorgan
Level 2 ●●
Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • July 31, 2020

I should note that the case in which all three are displayed has been solved, because I've just hardcoded the button in the last block. It's the one and two-block cases that I can't seem to figure out.


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • July 31, 2020

We need to change the next button text using java script.
Apply if logic on the embedded data, and based on the value, change the button text using below code:
jQuery("#NextButton").attr({"value":"Submit","title":"Submit"});


jpmorgan
Level 2 ●●
Forum|alt.badge.img+6
  • Author
  • Level 2 ●●
  • July 31, 2020

perfect! thank you, rondev