Execute Jquery after Relevance Equation executed

Plus d'informations
il y a 3 mois 2 jours #168884 par MadhuraBL
MadhuraBL a créé le sujet : Execute Jquery after Relevance Equation executed
Hi, I am trying to add a textarea for a single option in an Array question.

To achieve this,
1. I added 2 questions: 1-> Array; 2 -> LongFreeText
2. Added <span id="subQn2describe"> tag for Array subquestion where I need TextBox to appear

3. Added JavaScript for the Long free Text to hide this question but display only the textbox after Sub question 2 (Refer js code below)


       <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                var htmml = $("<div />").append($("#answer{SID}X{GID}X{QID}")).html();
                $('#subQn2describe').after(htmml);
                $('#question{QID}').hide();
            });
       </script>

This works just perfect (with text typed in textbox stored in backend).
But does not work when a RELEVANCE EQUATION is assigned to the questions (need RelEquation on both questions)

The custom js code is executed when survey is loaded, but is overwritten when Relevance Equation is executed.

My Survey structure: (display group by group)
Group 1:
Qn1: Name; Qn2: Gender; Qn3: Date of Birth
Group 2: (display group 3 only if age is less than 18yrs)
Qn1: Array question -> Relevance equation: (floor((time() - strtotime(Qn3)) / (60 * 60 * 24 * 365)) < 18)
Qn2: If Option 2, please describe -LongFreeText -> Relevance equation: (floor((time() - strtotime(Qn3)) / (60 * 60 * 24 * 365)) < 18) ( .hide() in js code)

Any suggestion on how to achieve this with Relevance Equation?

Note: with relevance eqn, my js code is overwritten and questions appear in the default way. i.e., Array Qn1 and Textarea Qn2 as separate questions.

Thanks in advance.
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 2 jours - il y a 3 mois 2 jours #168889 par Joffm
Joffm a répondu au sujet : Execute Jquery after Relevance Equation executed
Hi, MadhuraBL

my first idea was:
Why didn't you set the relevance equation on the group instead on each question?
You said the entire group is not displayed if older than 18.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Dernière édition: il y a 3 mois 2 jours par Joffm.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 2 jours #168894 par MadhuraBL
MadhuraBL a répondu au sujet : Execute Jquery after Relevance Equation executed
Hi Joffm,
Thanks for your reply. It somehow missed my mind that I could set relevance equation on group!

I just tried setting relevance equation on group and set RelEqn to "1" for all questions in the group. Still no luck! my custom code is still overwritten.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 1 jour #168908 par Joffm
Joffm a répondu au sujet : Execute Jquery after Relevance Equation executed
Hi,
here is a working example.
Of course it is a tpartner's script.

At the moment the open option is at the end, but you seem to be experienced in javascript, so you might adapt.


And in the sample there is also the relevance.

Fichier attaché :

Nom du fichier : limesurvey...5-18.lss
Taille du ficher :21 ko


Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Pièces jointes :
Les utilisateur(s) suivant ont remercié: MadhuraBL

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 mois 2 heures #168941 par MadhuraBL
MadhuraBL a répondu au sujet : Execute Jquery after Relevance Equation executed
Thanks Joffm, this is exactly what I wanted.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 mois 4 semaines - il y a 2 mois 4 semaines #168948 par MadhuraBL
MadhuraBL a répondu au sujet : Execute Jquery after Relevance Equation executed
Hi Joffm, I updated your script to adapt my requirement and everything was working fine, until I changed the Relevance Equation of the group to my original Regular Expression: (floor((time() - strtotime(Qn3)) / (60 * 60 * 24 * 365)) < 18).
I reverted the RelEqn back like in your sample code: A1<18 and the script worked! I then tested with my previous java script code with RelEqn A1<18 and that works as well.

So it was the Regular Expression in RelEqn causing the issue! Show/Hide of the groups with regular expression works perfectly fine, it's only the custom script that is overwritten to default display, with Regular Expression as Relevance Equation. Strange really!


Created Equation type question(Age) with regular expression in Logic.
Used Age<18 as Relevance equation for all other age related questions.


Thanks very much for your help and time, really appreciate it.
Dernière édition: il y a 2 mois 4 semaines par MadhuraBL.

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!