Have an idea?

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

Free Format JS not working with Safari

I have programmed a typing tool that combines the responses of a 5 task MaxDiff into a key for a lookup table using a very long list of if(lookup == 12121212  || lookup = xy...){segment =1;}else if(....

This works as intended in Chrome but I cannot get it work in Safari. The question DOES work if I remove the entire lookup and call only the string of numbers from the maxdiff to a hidden variable.

It seems that the problem also occurs in other browsers randomly. Do you know if this has occurred with other users or potential solutions?
asked Aug 28, 2020 by Stephen
Can you offer us some more information?  Your series of if statements probably work fine in Safari, but are there other things happening in your JavaScript?  Have you added some custom HTML or CSS to the page?

Would it be possible to upload a page that demonstrates the problem in Safari?
In the header of the FF: <body onload="segmentation();">
Variables:
<input name="Typing1_n" id="Typing1_n" type="hidden" value="">
<input name="Typing1_segment" id="Typing1_segment" type="hidden" value="">
html tag:
<script type="text/javascript">
function segmentation()
{

var num1 = [%Value(MXD1_1_b)%];
var num2 = [%Value(MXD1_1_w)%];
var num3 = [%Value(MXD2_1_b)%];
var num4 = [%Value(MXD2_1_w)%];
var num5 = [%Value(MXD3_1_b)%];
var num6 = [%Value(MXD3_1_w)%];
var num7 = [%Value(MXD4_1_b)%];
var num8 = [%Value(MXD4_1_w)%];
var num9 = [%Value(MXD5_1_b)%];
var num10 = [%Value(MXD5_1_w)%];
var n = "" + num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10;
var segment = 1;

document.getElementById("Typing1_n").value = n;
document.getElementById("Typing1_segment").value = segment;

}
</script>

The above works in Safari, but when I add the following code, inserted between var segment = 1; and document.getElement... it does not (code is a demonstration of what is there - there are thousands of lookups possible):
if(n==1212121212 || n==1213121212 || n==1312121212 ||...){segment=1;}
else if(n=....|| n==3124434343 || n==4113434343 || n==4114434343){segment=7;}

I have saved a copy of my survey and removed all custom formatting to ensure that nothing else was potentially interfering.
If you open Safari's dev tools, is there an error message in the console?  Looks like it can either be opened with Ctrl+Shift+J or Cmd+Opt+J.

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.
...