Have an idea?

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

Auto submit a page

Hi guys,

I have a page that only contain a free format which i fill automatically using the javascript in advanced tab, so basically i get this empty page and i have to press submit to continue, is there any why to auto submit or hide this page but still use it's function? Thanks.
asked Aug 1, 2019 by Ahmed Anwer Bronze (700 points)
Can you place it on another survey page with an existing question? That will remove the survey page you refer to. Ensure where you place it does not affect any skips.
No, I have to put in a separate page because i'm collecting some scores in this one (based on previous questions)
What about a future existing survey page after the applicable questions have been answered?
Yes, you can auto submit a page using sawtooth function "SSI_SubmitMe();". Call this function after your code in advanced part.
Can you detail what calculations are being done in the JavaScript?  It may be possible to keep the respondent from having to go to the free format question at all and instead run the calculations with unverified Perl.
Let's say i have 10 questions, and i'm calculating a total score for some responses in the free format by javascript in the very next page(after answering the 10 questions), so now i have to hide the free format input and fill it with this code "$("#xx").val(totalscore);" so the page is basically empty, and i have to put a text like "please press next" or something to hide the process of calculating this score
If you are just adding up some values from a previous page, you don't need to use a free format question on a new page.  You could perform the calculation using JavaScript and a free format on the very same page as the original respondent inputs, or use unverified Perl to run the calculations on the next page.
How would i run these calculations with unverified perl?
What are the exact calculations you are doing?
Let me break it down to you with a short example of what i'm trying to do, I have 2 question (A1,A2), each response has a score that has to be calculated as you see in this photo: https://i.ibb.co/TcwsstL/1.png . So this is my script: https://i.ibb.co/w4bB028/2.png . This is the free format question: https://i.ibb.co/mhbDpKW/3.png https://i.ibb.co/6g4MHF9/4.png , This is what i'm typing in the free format advanced tab: https://i.ibb.co/k60zWMb/5.png . After all of this, i hide the free format input and i get a blank page that i just want to avoid and keep using it's calculation
Note that for my actual survey there is at least 10 or 15 questions that i calculate scores for
I refer to the questions using [% %] not SSI_GetValue, you get the idea..   and i have to make the order of the questions as you see it, because the score determines showing/not showing the next questions

Like I was saying before, there are probably a few ways I might go about this.  If you are only using the score to determine one skip, I would probably put the calculation in the skip logic itself.  But if you want to re-use the score in multiple places, what I would do is move the Score question to the same page as A1 and A2, then give it this HTML:

<input name="[% QuestionName() %]_x" id="[% QuestionName() %]_x" type="hidden" value=""/>

function SSI_CustomGraphicalRadiobox() {

function SSI_CustomGraphicalCheckbox() {

function updateScore() {
    var score = 0;
    switch (SSI_GetValue('A1')) {
        case 1:
            score += 10;
        case 2:
            score += 15;
        case 3:
            score += 8;
    if (SSI_GetValue('A2_1')) {
        score += 5;
    if (SSI_GetValue('A2_2')) {
        score += 10;
    if (SSI_GetValue('A2_3')) {
        score += 20;
    $('#[% QuestionName() %]_x').val(score);

Now you're calculating the score on-the-fly as the respondent answers the questions, giving you a final value that's ready to go in skips or whatever when the respondent submits the page.
Very nice Zachary!

1 Answer

+1 vote
Just put this code in the footer of that question.

<body onload="doonload()"> <script language="javascript"> function doonload() { setTimeout('SSI_SubmitMe()',0);  } </script> 

answered Aug 1, 2019 by Jay Rutherford Gold (39,625 points)
Thank you man, it worked perfectly