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 by Ahmed Anwer (285 points)
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 by Jay Rutherford Gold (32,940 points)
Thank you man, it worked perfectly