[Solved] Populate Radio Button Grid with URL variable

0

I would like to pass an answer from the URL to a radio button grid.  In this case it is only 1 rows and 2 column headers. 

Morgan Berry asked

    Best answer

    1

    Hey Morgan,

    This is fairly simple using the following:

    sgapiURLValue – to capture the URL Variable

    IF statement – to compare the value from the URL Variable ( all custom scripting is php based, no need to add <?php ?> )

    sgapiSetValue – to set whatever value after the IF statement has run

    When you create a Radio Button Grid it creates a new Question ID for each row. So I would:

     

    1. Create Radio Button Grid
    2. Gather the specific question id from Radio Button Grid, you can:
      1. Use your browser developer tools or
      2. Use the Survey Legend under Tools Tab
    3. Create custom scripting and place it before the radio button grid so that it takes place before the question loads and sets the value properly.
    4. Use the following code:

      %%name = sgapiURLValue(“name”);

      if ( %%name == “jacob” ) {
      sgapiSetValue(5,”Column 2″);
      }

    This code I put together is saying … Set the variable %%name to what the URL Variable ?name=”” equals. If the name is equal to jacob then Set Value of the Radio Button Grid to “Column 2” // Column 2 is the value of the answer.

    Well if you have any other questions, feel free to let me know.

    Jacob Hayslett answered
      0

      OK.. so I think I found the problem.  I have another URL variable.. when I remove it and only have the csat.. it works.. when I add the other guid, it does not.  Does anyone have any thoughts?

      Morgan Berry answered
        0

        I tried this and it is not working for me.. Did I do something wrong?

         

        URLExample: https://MySurveySite/s3/CSSurvey?CSat=”1″
        (I have tried with and without quotes on the URL Variable)

         

        From Survey Legend:

        Code:

        %%CSat = sgapiURLValue(“CSat”);

        if ( %%CSat == “1”) {
        sgapiSetValue(22,”Yes”);
        }

        Morgan Berry answered
          • Hi Morgan,

            I am not an expert in this realm but I would not recommend using the quotes in your URL unless you are wanting to pass a string of information.

            One thing I would recommend is dropping the uppercase in “CSat” … instead replace it with “csat”. When I tested and did that it worked fine.

            Let me know what your results are.

          ×

          Login

          Question stats

          • Active
          • Views679 times
          • Answers3 answers
          • Followers0 followers