Have an idea?

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

Can the answers based on check boxes be pre selected in next question

How we can carry forward the selection on check boxes in next screen. For example in spontaneous awareness question I would like to get confirmation in the next question (showing complete brands list for confirmation). In the third question I would like to ask that what other brands one know in the list while ensuring that the brands selected in the last confirmation question be be already selected. How this can be done. Looking forward to the help.
asked Dec 21, 2012 by anonymous

1 Answer

+2 votes
Hi , you can use below scripts .

I have quesiotn Q13, and I need to check button based on Q13 responses. so i am storing previous status on bradn variable. and then checking ( if (brands[i] == 1)) if it is 1 check button for Q14 as well. you need to modify below code.

Please download jquery-1.7.1.min.js file. google it, you will get source.
<script type="text/javascript" src="/graphics/system/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function ($) {
        var brand1 = "[% Q13_c1 %]";
        var brand2 = "[% Q13_c2 %]";
        var brand3 = "[% Q13_c3 %]";
        var brand4 = "[% Q13_c4 %]";
        var brand5 = "[% Q13_c5 %]";

        var brand6 = "[% Q13_c6 %]";
        var brand7 = "[% Q13_c7 %]";
        var brand8 = "[% Q13_c8 %]";
        var brand9 = "[% Q13_c9 %]";
        var brand10 = "[% Q13_c10 %]";

        var brand11 = "[% Q13_c11 %]";
        var brand12 = "[% Q13_c12 %]";
        var brand13 = "[% Q13_c13 %]";
        var brand14 = "[% Q13_c14 %]";
        var brand15 = "[% Q13_c15 %]";

        var brand16 = "[% Q13_c16 %]";
        var brand17 = "[% Q13_c17 %]";
        var brand18 = "[% Q13_c18 %]";
        var brand19 = "[% Q13_c19 %]";
        var brand20 = "[% Q13_c20 %]";

        var brand21 = "[% Q13_c21 %]";
        var brand22 = "[% Q13_c22 %]";
        var brand23 = "[% Q13_c23 %]";
        var brand24 = "[% Q13_c24 %]";
        var brand25 = "[% Q13_c25 %]";

        var brand26 = "[% Q13_c26 %]";
        var brand27 = "[% Q13_c27 %]";
        var brand28 = "[% Q13_c28 %]";
        var brand29 = "[% Q13_c29 %]";
        var brand30 = "[% Q13_c30 %]";

        var brand31 = "[% Q13_c31 %]";
        var brand32 = "[% Q13_c32 %]";
        var brand33 = "[% Q13_c33 %]";
        var brand34 = "[% Q13_c34 %]";
        var brand35 = "[% Q13_c35 %]";
        var brand36 = "[% Q13_c36 %]";
        var brand37 = "[% Q13_c37 %]";
        var brand38 = "[% Q13_c38 %]";


        var brands = [brand1, brand2, brand3, brand4, brand5, brand6, brand7, brand8, brand9, brand10, brand11, brand12, brand13, brand14, brand15, brand16, brand17, brand18, brand19, brand20, brand21, brand22, brand23, brand24, brand25, brand26, brand27, brand28, brand29, brand30, brand31, brand32, brand33, brand34, brand35, brand36, brand37, brand38];

        var i = 1;
        for (i = 0; i <= 37; i++) {
            var j = i + 1;
            if (brands[i] == 1) {
                $("#Q14_r2_c" + j).attr("checked", "checked");
                $("#Q14_r2_c" + j + "_graphical").removeClass("checkbox");
                $("#Q14_r2_c" + j + "_graphical").addClass("checkboxselected");
                var clone = $("#Q14_r2_c" + j).parent("td").clone();
                $("#Q14_r2_c" + j + "_graphical").parent("td").replaceWith("<td>" + clone.html() + "</td>");
                if ($("#Q14_r1_c" + j + "_graphical").parent("td").hasClass("alt_color1")) {
                    $("#Q14_r2_c" + j + "_graphical").parent("td").addClass("alt_color1");
                } else {
                    $("#Q14_r2_c" + j + "_graphical").parent("td").addClass("alt_color2");
                }
                $("#Q14_r2_c" + j + "_graphical").css("cursor", "default");
            }
        }
    });
</script>



Let me know if need addtinal help.
answered Dec 21, 2012 by Rajesh Rana Gold (23,430 points)
I am very new working with J scripts, while placing the given below script I am getting the script error when I click preview. The error is "Expected ',' at line 46

The code is as follow:

<html>
<head>
<title>The jQuery Structure</title>
<script type="text/javascript" src="/graphics/system/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function ($) {
        var Gul Ahmed = "[% SpontConfirmation_1 %]";
        var Al Karam = "[% SpontConfirmation_2 %]";
        var Sana Safinaz = "[% SpontConfirmation_3 %]";
        var Kayseriya = "[% SpontConfirmation_4 %]";
        var MauSummery = "[% SpontConfirmation_5 %]";
 
        var Firdous = "[% SpontConfirmation_6 %]";
        var Five Star (Classic) = "[% SpontConfirmation_7 %]";
        var Elan = "[% SpontConfirmation_8 %]";
        var Lakhani (LSM) = "[% SpontConfirmation_9 %]";
        var Nishat = "[% SpontConfirmation_10 %]";
 
        var Mehdi = "[% SpontConfirmation_11 %]";
        var Asim Jofa = "[% SpontConfirmation_12 %]";
        var Maria B = "[% SpontConfirmation_13 %]";
        var JJ = "[% SpontConfirmation_14 %]";
        var Ittehad = "[% SpontConfirmation_15 %]";
 
        var Crescent = "[% SpontConfirmation_16 %]";
        var Umar Sayeed = "[% SpontConfirmation_17 %]";
        var HSY = "[% SpontConfirmation_18 %]";
        var Taana Baana = "[% SpontConfirmation_19 %]";
        var Other1 = "[% SpontConfirmation_20 %]";
 
        var Other2 = "[% SpontConfirmation_21 %]";
        var Other3 = "[% SpontConfirmation_22 %]";
  
 
        var brands = [Gul Ahmed, Al Karam, Sana Safinaz, Kayseriya, MauSummery, Firdous, Five Star (Classic), Elan, Lakhani (LSM), Nishat, Mehdi, Asim Jofa, Maria B, JJ, Ittehad, Crescent, Umar Sayeed, HSY, Taana Baana, Other1, Other2, Other3];
 
        var i = 1;
        for (i = 0; i <= 37; i++) {
            var j = i + 1;
            if (brands[i] == 1) {
                $("#AidedAwareness" + j).attr("checked", "checked");
                $("#AidedAwareness" + j + "_graphical").removeClass("checkbox");
                $("#AidedAwareness" + j + "_graphical").addClass("checkboxselected");
                var clone = $("#AidedAwareness" + j).parent("td").clone();
                $("#AidedAwareness" + j + "_graphical").parent("td").replaceWith("<td>" + clone.html() + "</td>");
                if ($("#Q14_r1_c" + j + "_graphical").parent("td").hasClass("alt_color1")) {
                    $("#AidedAwareness" + j + "_graphical").parent("td").addClass("alt_color1");
                } else {
                    $("#AidedAwareness" + j + "_graphical").parent("td").addClass("alt_color2");
                }
                $("#AidedAwareness" + j + "_graphical").css("cursor", "default");
            }
        }
    });
</script>

</head>

<body>
What other brands do you already aware of. Select from the list.<br><br>

<b><u>Note:</u></b> Don't unselect already selected brands.
</body>
</html>

Can you please further help on this.
Thanks
P.S. have downloaded and placed jquery-1.7.1.min.js in the graphics directory.
Right click on the web page giving the error and choose view source.  What line of code is on line 46?
No spaces allowed in variable names.  For instance, instead of

var Al Karam

try

var Al_Karam

Change it everywhere in your code.
Can you please confirm if scripts based on jquery work in SSI Version 6.6.18?
...