How do I retrieve the answer to a question using JavaScript?


This is not made clear anywhere in the documentation. sgapiGetValue is part of their PHP-like API but unless I’m missing something, that function is not available using Javascript. Merge codes are easy to use w/ PHP scripting but what’s the equivalent in JavaScript? 


freestyle35 answered

    The first link makes a statement that I had overlooked but it’s very important: “Custom Scripting runs server side and JavaScript runs client side.” The doc should point out one very important distinction and limitation to JavaScript in SurveyGizmo. Server-side gives you access to what’s on the server (e.g. questions and other meta data for any question on any page). This is made simple using merge-codes. Client-side limits your access to what’s loaded on the current page. JavaScript does have server-side capabilities (e.g. using the very friendly jQuery API around AJAX but SurveyGizmo hasn’t implemented this). Bottom line: if you want to access information from prior pages, it’s best to use scripting (PHP). You could put together a clunky JavaScript solution but storing the info you want in a hidden value on the current page, then getting that element id, etc… but that’s a bit of a kludge.

    thanks for the info

    freestyle35 answered

      There is an example of the difference between using sgGetValue and the JavaScript method in the SurveyGizmo API section of the documentation (  In JavaScript you obtain the answer value thru the  element IDs  (

      The code and a working example of this method can be found in the documentation at

      Good luck!

      Jim W (Moderator) edited answer


        Question stats

        • Active
        • Views277 times
        • Answers2 answers
        • Followers1 follower