Hi Survey JS Devs,
I'm making an anonymous form that computes an adjustment to a base rate as a sliding scale implementation.
The code is on Codepen here.
I compute some values and create some text to show on the thank you page, with variable completeText
. Based on the example NPS Survey Question I made an update of the survey.completeText
within the survey.onComplete
callback. However, I find that the survey just freezes after clicking the complete button. The math and JS Indexing used to make the completeText
didn't seem possible with an expression, so I just did it with vanilla JS.
How can I go about getting the thank you text to update when the user clicks the Complete button?
Custom Thank You Message computer from survey answers
Show previous comments
(0)
Comments
(0)
Sign in to comment on this post
Answers approved by surveyjs Support
created 2 months ago
(modified 2 months ago)
Hello,
Please use the survey.onProcessHtml
function to update a Thank You message for your survey.
JavaScriptsurvey.onProcessHtml.add((sender, options) => {
if(options.reason != "completed") return;
let data = sender.data;
let k = Object.keys(data);
let has_br = Boolean(data.base_rate);
let rate;
//...
options.html = "Your adjusted rate is: " + roundCent(rate);
Consider the updated demo: View Demo.
Let me know if you require further assistance.
Comments
(1)
SH
2 months ago
Using the onProcessHtml.add
callback appears to work, though slightly differently than anticipated. I modified the sender.options.html
value and it worked. The Codepen has been updated accordingly. Thank you @Jane! This is going to be used for a non-profit, non-commercially, is there any way to donate a one-off via Ko-fi or the like?