Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Referencing subquestions in JavaScript (LS7)

More
3 weeks 6 hours ago - 3 weeks 6 hours ago #275298 by squidy
Your LimeSurvey version: 7.7
Own server or LimeSurvey hosting: self-hosted
Survey theme/template: Fruity TwentyThree
==================

In LimeSurvey 3.x it was possible to directly reference a subquestion using JavaScript code similar to this:

$("#answer{SGQ}SQ001").mask("(99) 99999-9999", { placeholder: " " });

How can this be done in version 7 without having to specify the exact ID of the subquestion?
 

Upgrading to LS 7.x
Last edit: 3 weeks 6 hours ago by squidy.

Please Log in to join the conversation.

More
3 weeks 4 hours ago - 3 weeks 3 hours ago #275299 by Joffm
Hi,
I always do it this way using {QID}.
No matter whether with the script of Igor Escobar (which you use as you said some time ago)
$('#question{QID} .question-item:eq(2) input[type="text"]').mask('(000) 000-0000', { placeholder: "(123) 456-7890" });
or the one of Robin Herbots 
$('#question{QID} .question-item:eq(3) input[type="text"]').inputmask({
            'mask': '(999) 999-9999',
            'placeholder': '(123) 456-7890',
            'removeMaskOnSubmit': false,
            'rightAlign': false,
        });



Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 3 weeks 3 hours ago by Joffm.

Please Log in to join the conversation.

More
2 days 11 hours ago #275342 by Mazi
squidy, can you share a link to an activated sample survey and let us know which element you want ti address?

Thing is that at version 7, fields are named differently (see www.limesurvey.org/manual/LimeSurvey_7_Fieldname_Refactor ), therefore JS code applied to older versions may not work any more.

Best regards/Beste Grüße,
Dr. Marcel Minke
survey-consulting.com
offlinesurveys.com
Feel free to contact me by email for professional LimeSurvey support!

Please Log in to join the conversation.

Moderators: tpartner, holch

Lime-years ahead

Online-surveys for every purse and purpose