Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

Remove pre-filled zero from constant sum (WITH BARS)

DW2020
DW2020 Community Member Qubie ✭
edited August 4 in Custom Code

I have a question regarding the correct java code for removing pre-filled zeros from a constant sum question. While I am aware of how to do this for a constant sum question with choices only (https://community.qualtrics.com/XMcommunity/discussion/2531/constant-sum-without-prefilled-0), the code does not seem to work for constant sum questions with bars.

I appreciate your help!

Best Answer

  • JeremyK
    JeremyK Lenexa, KSCommunity Member, Qualtrics Brand Admin Sage ✭✭✭
    Accepted Answer

    Hey @DW2020, don't know if you solved your problem or not, but I can shed some light on it for you. In a Constant Sum: Choices question, the elements are in a list (li). In Constant Sum: Bars, the elements are built out in a table (td). Changing your code to

    jQuery("#"+this.questionId+" td input[type=text]").val("");
    

    will change the value of the zeros when the type is set to bars. I'm struggling to get this to work because the JS is firing twice, once for the desktop view and then a second time for the mobile view. The first time through, all zeros are wiped out and it all looks good. The second time through, the zeros are added back in (thanks mobile) and I'm not sure how to suppress that. Still working on it, but the above code will have you grabbing and changing the correct elements at least.

Answers

  • DW2020
    DW2020 Community Member Qubie ✭

    Thanks @JeremyK for your answer! That's a very helpful first step. If you find a solution to the issue you mentioned, I would be very happy to hear how you solved it.