Have an idea?

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

Using JavaScript to Set Values in 6.6.18

Where do I put a script to set values in 6.6.18? I've got JQuery running and want to store the ranking for sortable elements.

I can get to parsing each part of the toArray event into separate variables but I don't know where to put the script to make it process the results of the sorting and push into the variables.

Do I use: "document.getElementById("sortabletest1_product1").value = sort1Rank;?"

Where "sortabletest1_product1" is a variable name in a freeform item?
asked Oct 9, 2017 by Corey1975 Bronze (780 points)
The code needs to be put into an event that fires when your relevant page elements are interacted with.  Are you using jQuery UI's "sortable" by chance?  If not, what are you using?
I'm using jQuery UI's "sortable."

I tried both the footer and the custom verification but neither worked. I have alerts in the script for debugging and none fired (including the ones that tell me the script is working.

If I set the custom verification to trigger before the system verification, it will run but I still can't get the values to push to the variables.
Figured it out.

Changed the variables in the Variable Names panel to hidden variables and then added hidden inputs. That allowed the sortable scripting to import the values to the hidden variables.
That's great to hear.  Sorry I wasn't able to get back to you more quickly.

Your solution to the original question

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.