Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

using a function to subit page and skip to a page

Lets say I have a 5 page survey. In the survey page footer i'd like to create a trigger that when clicked will submit the page and take the respondent to page 5. So if the person is on page2 and clicks the trigger in the footer, the page submits and then displays page5. If the back button on page5 is click they return to page2. If the submit the page with the next button they proceed to page3. On page3 if they again click the trigger in the footer the page submits and they go to page5. Now on page5 if the back button is clicked they return to page 3...etc

I created a function that executes when the trigger is clicked but I can't determine the best way to get the skip to occur. I tried using a pass-in variable and even a hidden variable and resubmit its value when the trigger is clicked and create a post skip on that variable but could not get that to work. Ideas? Thanks.
asked Apr 22 by Chris Guth Bronze (985 points)
I've never done anything like this before, but I wonder if you could try to make a variable as a flag.  For example, the footer would use the SetValue() function to change an unused variable (pass-in or a hidden variable on a free format page nobody would see) to a 1.  Each question would have a pre-skip on it so that if Var=1, skip to page 5.  Your footer could call the submit JavaScript function we have and set the variable and it would just go to the next page, but the next page would just skip.

If the normal next button is pushed, the variable is set to 0 and the skip doesn't execute.

I'm not 100% sure exactly if that would work how you want it, but that would be how I might approach it.
Thanks for replying. I thought about using SETVALUE but since SETVALUE is SSI script it runs before any of the javascript, therefore SETVALUE will always set the value to 1 and the skip will always occur. That's if i am understanding your suggestion correctly.
I think you're right and that approach is flawed.  Still kind of thinking out loud, maybe you could add a free format question to every page with no content but a hidden variable.  The hidden variable is set to 0 when the page loads (ssi_ready), and then if the footer element is clicked on, it could set the hidden variable to 1 and submit the page?  Then similar skip logic could be based on the subsequent questions?  Feels really messy since you'd have to have a hidden variable and separate skips on every page I think, but I can't really think of a more elegant way to do it.

Another thinking out loud, maybe if the banner is clicked, any answers on the page are cleared and the page is submitted, and then you could base your skip logic on using the Answered() SSI Script function (or rather, "not Answered(QuestionName)") in the skip logic?
Yeah, I was trying to avoid create a new var on each page to execute the same skip. Thought maybe is I could create the var in the survey footer it'd be accessible throughout the whole survey. Is there a way to set a temp var that could trigger a skip?  more thinking out loud. Could be that it's just not possible. Sawtooth is pretty dynamic though so wanted to give it a try.
Yeah the tricky part is trying to mix JavaScript executing in real time based on clicks and mix it with stuff like skip logic, which evaluates essentially in-between questions up on the server and looks at database fields.  So you can't really make something instanced in some code in the footer of the page and reference it outside of that instance (as soon as the page submits, your JavaScript effectively doesn't exist anymore).

There definitely might be a way to do it but I can't think of anything particularly slick

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.