Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Populate open from previous response

I know I had found the code for this previously, but am coming up empty handed here today.

I simply need to populate an open in a grid with a response from a previous page, if there is one. In this case the respondent is asked for their name and email, currently in a grid with two rows and one column, and each row has a single line open text box.  They are then asked about participating in another project, and if they are they will be asked for this information another time - in case they didn't enter previously. I want to auto fill the second request with the name and email from the previous request, if they gave them, so they don't have to re-enter the information. I believe this is a simply getElementById and setting the value, but seem to be dropping the ball somewhere.
asked Nov 28, 2017 by Ron H.

1 Answer

0 votes
Try adding this to the second grid question:

    if (!$('#GridQ2_r1_c1').val().length) {
        $('#GridQ2_r1_c1').val('[% GridQ1_r1_c1 %]');

"GridQ1" and "GridQ2" must be replaced with the names of the first and second grid questions, respectively.
answered Nov 28, 2017 by Zachary Platinum Sawtooth Software, Inc. (147,200 points)
Hi Zachary,

Thank you for sending that along. Sadly, I was unable to get that code to work.
What behavior are you observing?

Are there any error messages in your browser's console when you use the code?  (The console can be found within the dev tools, opened by clicking F12 in your browser.)