Multiplication of two fields for use later in survey

0

In a survey I’m building, I need to ask respondents to provide three dimension answers (Length, width and depth).  I need to mulitply the three, and use the result in a later question.  I’ve tried copying and using the code from the same multiplication calculation, but there is no clear indication about (1) how to populate the sgapigetvalue, or (2) how to save the output for later use.

The code provided in the example is:

%%numberofshirts = sgapiGetValue(5); //Get value of first textbox
%%shirtprice = 15; //Replace 15 with amount of shirt

%%totalamountdue = (%%numberofshirts * %%shirtprice); //Multiply the first textbox times the shirt amount

sgapiSetValue(6,%%totalamountdue); // Change 6 to ID of Hidden Value or Textbox

I need to understand how to populate the fields (in the example %%numberofshirts is being sourced from sgapiGetValue(5), but there’s no explanation about how I should define where the GetValue comes from.  I also need to understand how to use the output as a field in following questions.

Any advice will be greatly received!

rlarkins answered
    0

    Hi Lola

    Thanks for your answer. Unfortunately, it presumes I know more than I do. I’ve already been to all the pages you’ve identified, but they don’t actually provide the detail.  For example:  How to find Question IDs.  I have that option turned on in my view settings. It states: 

    Throughout the survey, you will have your Question IDs and Page IDs available to you… Question IDs will be visible under every survey question.

    However, this is not the case. I can clearly see the Page IDs, but no Question IDs. So I don’t know how to populate the question to source the available data. I’ve uploaded to screen shots showing (1) the Page ID; and (2) the absence of any Question ID.

    My intention is to save the result in a hidden value. Again, the issue is that there is no explanation of the code required to do this in the Gizmo documentation. And the working example template they have doesn’t seem to have any code that I can copy-and-paste/ reverse engineer into my question.

    Any further help would be greatly appreciated!

     

    rlarkins answered
      0
      Lola Gill 6.78K Rep.

      The GetValue pulls information from a survey question (identified by the question’s ‘Question ID’):

      https://script.surveygizmo.com/help/sgapigetvalue

      This document should help you track down Question ID numbers:

      https://help.surveygizmo.com/help/how-to-find-ids

      When you use the SetValue function, you also are setting the value of a question via the ID:

      https://script.surveygizmo.com/help/sgapisetvalue

      One option is to create a Hidden Value on your survey and and populate the Hidden Value with the outcome to your multiplication via the SetValue function.

      Hope this helps you get started!

      Lola Gill answered
        ×

        Login

        Question stats

        • Active
        • Views1143 times
        • Answers2 answers
        • Followers1 follower