Question about custom scripting – hiding questions



I’m on a legacy account, with custom scripting enabled.

Trying to figure out custom scripting better and running into difficulties… Here goes:

I have a textbox grid question, ID: 22.

I have a checkbox question under the textbox grid with a single option “Don’t know”, its reporting value = 1

The checkbox ID: 107 and the its option is OPTION: 10174

I want the textbox grid to hide if the option is selected and to appear if it is un-selected.

I tried the hiding bit by using the following custom scripting code (which doesn’t work):

if (sgapiGetValue(10174)==’1′) sgapiHideQuestion(22, true);


I also tried:

%%dontknow = sgapiGetValue(107);
if (sgapiArrayGet(%%dontknow,10174)==’1′) {
   sgapiHideQuestion(22, true);

(Also tried replacing the ‘1’ by “Don’t know” as the string in the if statement).

But that, too, didn’t do anything… Please help…

Note that since “don’t know” option is under the textbox grid and not above, the default logic won’t work to show/hide the textbox grid.




Jacob H (Moderator) answered

    Hi Adi,

    Before getting into how it is all written up, are you trying to hide the question on the same page?

    The reason you may be experiencing these issues is with the method of execution. What I mean by that is, the custom scripting is PHP based, which means it is ran server side. This means that once the page loads, the PHP has executed and is complete.

    In cases where you would like actions to take place on the same page, you can use JavaScript.

    I have used a combination of both JavaScript and Custom Scripting to come up with many different solutions.

    SurveyGizmo Documentation Team has done a great job in putting together a document that goes over this.

    If this doesn’t answer your question, please add any information that we might be able to assist with.

    adi commented
      • Hi Jacob,
        You are completely right – custom scripting can’t help here since once the page loads the script finishes and that’s it. Yes, the two are on the same page.

        The documentation is great, but my JavaScript is a little rusty (or non existent).

        Basically I wanted to hide a question based on a click on a specific option in a multiple choice question. The two questions are on the same page.

        I’ll try to figure this out better once I have the time to go through the documentation.




      Question stats

      • Active
      • Views311 times
      • Answers1 answer
      • Followers1 follower