Have an idea?

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

Auto submit without clicking Next button

Hi,

I have a survey where half of it will be done online and half of it CAPI. Therefore I have a question Sample which should be auto coded and skipped for let's say UK and shown to Egypt.

For UK xSample variable will be passed in with the link so wrote some JavaScript and put it in the Footer of Sample question. Then I've tried adding SSI_SubmitMe() or SSI_subSubmitMe() at the end but it doesn't work at all. Well auto coding does work but auto submit not.

<script type="text/javascript">
  var ss = [%xSample%];
  if (ss == 1) {
      SSI_SetSelect("Sample_1", true);
  }
  if (ss == 2) {
      SSI_SetSelect("Sample_2", true);
  }
  if (ss == 3) {
      SSI_SetSelect("Sample_3", true);
  }

</script>

What I am doing wrong? Is there any other way to do this? I must have Sample variable because most of the questions are country specific and all my condition were set on it.

Please help.
asked Jan 23, 2013 by steevas (120 points)
Can you independently trigger the SetSelect() and calling the submit function?  If so, then it seems like it would be a syntax issue somewhere if you put them together and it doesn't work.
SetSelect() works but SubmitMe() does not work independently. My full script looks like this:
<script type="text/javascript">
  var ss = [%xSample%];
  if (ss == 1) {
      SSI_SetSelect("Sample_1", true);
  }
  if (ss == 2) {
      SSI_SetSelect("Sample_2", true);
  }
  if (ss == 3) {
      SSI_SetSelect("Sample_3", true);
  }

  if (ss > 0 && ss < 4) {
      SSI_SubmitMe();
  }
</script>

Maybe it is the wrong place? Or my Sawtooth version is too old?

1 Answer

+2 votes
Did you use document.mainform.submit(). Please check with following code.

<script type="text/javascript">
  var ss = [%xSample%];
  if (ss == 1) {
      SSI_SetSelect("Sample_1", true);
  }
  if (ss == 2) {
      SSI_SetSelect("Sample_2", true);
  }
  if (ss == 3) {
      SSI_SetSelect("Sample_3", true);
  }

  if (ss > 0 && ss < 4) {
      document.mainform.submit();
  }
</script>
answered Feb 27, 2013 by Rajesh Rana Gold (23,355 points)
...