Applying custom script problems

0

hello,

 

I have a radio grid with lots of options, rather than show them all, id like to randomise what is shown and cap it at 10

Theres no way to do this in the functions but I found a tutorial in the help screens which had the custom script to apply – but it doesnt seem to work.

I added a custom script action above the question i wanted to apply it to, and used this – 

 

//Row IDs to be randomly hidden go here. Make sure they are comma separated, no spaces, and inside quotes.
%%questionsHideRan = “1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26” ;

//Number of rows you want shown from the list above. No quotes or commas are needed.
%%shown = 10;

//Do not change after this line.
%%arr = sgapiExplode(‘,’,%%questionsHideRan);
sgapiShuffle(%%arr);
foreach(%%arr as %%question)
{
sgapiHideQuestion(%%question,true);
}
for (%%i=0; %%i<%%shown; %%i++)
{
sgapiHideQuestion(%%arr[”.%%i],false);
}

 

Has anyone used one of these before? any ideas why it wouldnt work?

 

thanks

 

Sam Thomas answered
    0

    ah! interesting, i thought it could be something to do with the row ids. i tried substituting with the question names but that didnt work. couldnt figure out how the row ids were labelled – i will have at the link- thanks

    Sam Thomas answered
      1

      chat with the team noticed a missing bracket, so the main problem was just incorrect row ids

       

      thanks for the help

      Sam Thomas answered
        0

         hm. found the row ids and swapped them but no dice.

        Have tested using a live link and all options are showing everytime

        Action was embedded before the question

        Sam Thomas edited answer
          1
          IS 2.20K Rep.

          How were you testing? If using the Preview/Test mode, did you change the “Fire Actions” toggle to on (green)? 

          Was the script above/before the questions to be hidden?

          I assume the Row IDs you included are just placeholders. It is not possible for the question ID for a radio button grid row to be 1 (the whole grid could have question ID 1 but the individual rows would have numbers higher than the overall grid).

          IS answered
            1

            The trouble is likely with the row IDs after the %%questionsHideRan function.

            It would be very surprising for the grid rows to begin with ID 1 (the IDs are not an indication of the row order, but rather a unique number assigned by SurveyGizmo each time a question/row is created).

            This document covers a couple of options for tracking down IDs within SG:

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

            Hope this helps!

            Dominic Sharpe answered
              ×

              Login

              Question stats

              • Active
              • Views2514 times
              • Answers5 answers
              • Followers1 follower