Have an idea?

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

Write directly to pass-in using javascript

Hey guys,

is it possible to write directly to a pass-in field using javascript.

What I want is to create a pass-in field as an input that is available on all page and write a value to it with javascript when I need to.

var permanent = '[%permpassin%]';


However I do not know how to correctly adress the field, since I can not call it with document.getElementById or similar methods.

Any suggestions?
asked Jan 6, 2017 by lieferant (320 points)
Unfortunately, I don't believe it's currently possible to update a value in the database using JavaScript.  The best alternative might be to include an open end question on each page, then use some script so that edits made on one page show up on the next page.  This would take up one data field for every page of your survey.
Zachary, can't you use SetValue an the applicable pages to change the value of the pass-in field?
SetValue, like all Sawtooth Script / unverified Perl, is ran on page load.  As such, it cannot be used in conditional JavaScript (e.g., run a Sawtooth Script every time the respondent clicks a check box).  Here's an example of the type of code that would update the pass-in field every time a respondent made a change to a text box on the page:

    [% SetValue(...) %]

This code doesn't work, though.  The Sawtooth Script is ran to completion before the JavaScript even starts.
Understand the SetValue command is run on page load.

I have used SetValue to update a variable (pass-in field or question variable) on numerous pages.

But if the variable requires updating on actions within the page, and you require immediate updating of the variable, I can see how SetValue is not the answer.

If it's just a simple update of the pass-in variable on numerous pages upon load, SetValue is okay.
i See. thank you anyway. maybe this is something that could be passed on to the dev team?
This might be the feature I bug the dev team about the most.  There's all sorts of cool things I could do with some sort of SSI_SetValue.
Good one Zachary. Sounds like a bright idea. I'm on your side mate.

Your answer

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.