Have an idea?

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

When piping text from one grid to another, values get cut off after comma

Hi,

I'm piping answers from one open-ended grid cell to another. The values in the initial open-ended grid cell are numeric, but I'd like to give respondents the option of entering commas for numbers >1,000 and I'd prefer not to deal with the approach laid out in Sawtooth's "I would like to add a thousands separator to a numeric field as people type in an answer" webpage, so I'm just using an open-ended grid cell and I'll do some post-processing of the inputs.

Trouble is, when I pipe an open-ended entry from one grid cell to another, any values after a comma get cut off. When I simply ask Sawtooth to display GETVALUE("Q3_r1_c1"), it shows the whole number, but with m code below, numbers/text after the comma are removed. (My code below pipes values from one grid in Q3 to a grid in Q4).

I think I'll be ready to launch my survey after I resolve this minor issue. How can I avoid this problem?

Thanks very much.


<script>
$('#Q4_r1_c1').val([% Begin Unverified Perl
GETVALUE("Q3_r1_c1")
End Unverified %])
$('#Q4_r2_c1').val([% Begin Unverified Perl
GETVALUE("Q3_r2_c1")
End Unverified %])
$('#Q4_r3_c1').val([% Begin Unverified Perl
GETVALUE("Q3_r3_c1")
End Unverified %])
$('#Q4_r1_c2').val([% Begin Unverified Perl
GETVALUE("Q3_r1_c2")
End Unverified %])
$('#Q4_r2_c2').val([% Begin Unverified Perl
GETVALUE("Q3_r2_c2")
End Unverified %])
$('#Q4_r3_c2').val([% Begin Unverified Perl
GETVALUE("Q3_r3_c2")
End Unverified %])

$('#Q4_r1_c1').prop('disabled',true)
$('#Q4_r2_c1').prop('disabled',true)
$('#Q4_r3_c1').prop('disabled',true)
$('#Q4_r1_c2').prop('disabled',true)
$('#Q4_r2_c2').prop('disabled',true)
$('#Q4_r3_c2').prop('disabled',true)

</script>
asked May 22 by pjwomble (210 points)

1 Answer

+2 votes
JavaScript requires that text be surrounded by quotation marks or apostrophes, but Sawtooth Script doesn't automatically produce quotation marks around text values.  To fix this, you just need to surround your Sawtooth Script with quotation marks or apostrophes.  Here's an example for the first line of your code:

$('#Q4_r1_c1').val('[% Q3_r1_c1 %]');
answered May 22 by Zachary Platinum Sawtooth Software, Inc. (63,875 points)
Easy enough -- thanks!
...