[Résolu] conditions d'un bouton

  • beheliod
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 29
  • Thank you received: 0

beheliod created the topic: [Résolu] conditions d'un bouton

Bonjour
Il est possible de mettre une condition pour faire apparaître ou non un bouton si on choisit une pagination personnalisée.
Mais est-il possible de mettre une condition multiple pour que le bouton apparaisse si une liste de questions définies est bien remplie

Par exemple quelque soit la réponse sur les boutons radios.
Si on répond au question 1,2,3 et 5 le bouton suivant apparaîtra
On ne prends pas en compte volontairement la question 4
Par avance merci pour votre aide.
Cordialement

Hello
It is possible to set a condition to make a button appear or not if you choose a custom pagination.
But is it possible to put a multiple condition for the button to appear if a list of defined questions is filled in?

For example, whatever the answer is on the radio buttons.
If we answer question 1,2,3 and 5 the following button will appear
Voluntary question 4 is not considered
Thanks in advance for your help.

Best regards
#235721
  • Posts: 3128
  • Karma: 105
  • Thank you received: 413

mihaela replied the topic: conditions d'un bouton

Hello,

It is possible to put a multiple conditions for the button to appear if a list of defined questions is filled in.

It can be done using JavaScript visibility rules as explained here crosstec.org/en/support/online-documenta...s-in-javascript.html .

To send you the correct code which will work as you want, I must know which type of elements are the questions. Are they all radio buttons?

Regards,

Mihaela
#235738
  • beheliod
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 29
  • Thank you received: 0

beheliod replied the topic: conditions d'un bouton

Hi Mihaela !
To your exemple I don't have any problem while there's only one condtion by question.

Personaly I prefer if my answers are :
question 1 = "yes" and question 2 = "yes", section "newsection" appears

But if question 1 = "no" and/or question 2 = "no", section "newsection" not appears and better, section 'othersection" appears

I hope I have been more specific in my request

Best regards
#235782
  • Posts: 327
  • Karma: 2
  • Thank you received: 51

Eddy.vh replied the topic: conditions d'un bouton

Bonjour Olivier.

Je javascript permet l'utilisation d'opérateurs logiques "et" (&&) et "ou" (||).
Il faudra alors probablement écrire ton script dans l'onglet Scripts des options avancées de ton formulaire.
#235979
  • Posts: 3128
  • Karma: 105
  • Thank you received: 413

mihaela replied the topic: conditions d'un bouton

Hello,

Yes, as Eddie wrote in that case logical operators needs to be used for multiple conditions.
function ff_question1_action(element, action) {
    
          if (jQuery('[name="ff_nm_question1[]"]:checked').val() == "yes" && jQuery('[name="ff_nm_question2[]"]:checked').val() == "yes" )
          {
               bfToggleFields('on','section','newsection',bfDeactivateField);
          }
          else
          {
               bfToggleFields('off','section','newsection',bfDeactivateField);
          }
           if (jQuery('[name="ff_nm_question1[]"]:checked').val() == "no" || jQuery('[name="ff_nm_question2[]"]:checked').val() == "yes" )
          {
               bfToggleFields('on','section','othersection',bfDeactivateField);
          }
          else
          {
               bfToggleFields('off','section','othersection',bfDeactivateField);
          }
        
} // ff_question1_action
NOTE: In the code above you have to replace every instance of "question1" with the name of radio group element with the question 1. Also, you have to replace every instance of "question2" with the name of radio group element with the question 2.
Also, "newsection" and "othersection" have to be the names of the sections to show or hide.

Let me know whether this works as you wanted.

You need to put this code in Actionscript of second question as well.
Code there would look like this:
[code]function ff_question2_action(element, action) {
    
          if (jQuery('[name="ff_nm_question1[]"]:checked').val() == "yes" && jQuery('[name="ff_nm_question2[]"]:checked').val() == "yes" )
          {
               bfToggleFields('on','section','newsection',bfDeactivateField);
          }
          else
          {
               bfToggleFields('off','section','newsection',bfDeactivateField);
          }
           if (jQuery('[name="ff_nm_question1[]"]:checked').val() == "no" || jQuery('[name="ff_nm_question2[]"]:checked').val() == "yes" )
          {
               bfToggleFields('on','section','othersection',bfDeactivateField);
          }
          else
          {
               bfToggleFields('off','section','othersection',bfDeactivateField);
          }
        
} // ff_question2_action
[/code]

What this will do is it will show section "newsection" if both questions 1 and 2 are answered with "yes" and hidden otherwise. If one of the questions 1 or 2 is answered with "no" "othersection" will be shown.

The code has to be put in actionscripts of each element whose response determines which section is shown or hidden.

There is other option to put all the code in Initscript. Here crosstec.org/en/forums/15-usage/126099-s....html?start=6#235186 you can take look at the example.

Let me know whether this is working as you wanted and whether you have managed to set this for your form.

Regards,

Mihaela
#235994
The following user(s) said Thank You: beheliod
  • beheliod
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 29
  • Thank you received: 0

beheliod replied the topic: conditions d'un bouton

Hello
I hope it's ok
Thank you very much
Best regards
#236059
Time to create page: 0.052 seconds

We Are Doing Our Part

Massive discounts on all of our extension subscription plans to help you and your business in these times.

Get Your Subscription Here

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

We are doing our part and support your business with extremely low prices -- For example 6-Months-Subscription for only $9 USD. For as long as necessary.

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!