Conditional fields - Checkbox

  • nigel
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 130
  • Thank you received: 1

nigel created the topic: Conditional fields - Checkbox

I have added this visibility rule

turn on element minLoc if status is Locum
turn off element minLoc if status is Full Time
turn off element minLoc if status is Part Time

However I need element minLoc to be visible if it is selected as well as Full Time or Part Time.

So minLoc would only show if the following were checked:

Locum
Locum & Full Time
Locum & Part Time
Locum & Full Time & Part Time

How can I get this result ?
#234578
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Conditional fields - Checkbox

Hello,

Since in this case multiple conditions are required to make the visibility rules work as you want you have to write Javascript visibility rules.

In this piece of documentation crosstec.org/en/support/online-documenta...s-in-javascript.html it is explained how to make the visibility rules work.

This topic might be useful to you as well crosstec.org/en/forums/breezing-commerce...e-plugin.html#220458 .

Let me know whether you have managed to make it work as you wanted. If you have more questions regarding this, feel free to ask.

Regards,

Mihaela
#234584
  • nigel
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 130
  • Thank you received: 1

nigel replied the topic: Conditional fields - Checkbox

Hi,


I have read the article and got lost

So far I have done this

turn on section main if status is Full Time
turn on section main if status is Part Time
turn on section locummin if status is Locum

turn off section main if status is !unchecked

turn off section locummin if status is !unchecked



Which works, but if I uncheck any of the options everything disappears
#234605
  • mihaela
  • Away
  • Administrator
  • Administrator
  • Posts: 1938
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: Conditional fields - Checkbox

Hello,

Yes, that won't work.

The following visibility rule turns off section mail in case any of options in the checkbox group main is unchecked:
turn off section main if status is !unchecked

Therefore, in cases like this you have to use JavaScript Visibility rules.

Here is how to make the example form your first post to work.

Please go to Advanced properties of the "status" element, and in Actionscript section set Type to Custom and Action to Change. In the code area below put the following code:
function ff_status_action(element, action)
{
     vals = '';
opts =  JQuery("[name=\"ff_nm_status[]\"]");
for (o = 0; o < opts.length; o++){
    if (opts[o].value == "Locum") {  
        if( opts[o].checked) { return bfToggleFields('on', 'element', 'minLoc', bfDeactivateField); }
        else { return bfToggleFields('off', 'element', 'minLoc', bfDeactivateField);  }
        }
    }

} // ff_status_action

That will turn on element "minLoc" if in "status" checkbox group "Locum" is checked (other options can be checked at the same time as well).

As stated in this piece of documentation crosstec.org/en/support/online-documenta...s-in-javascript.html :
"To use this method you must have previously defined at least one dummy visibility rule like:

turn on element mydummy if yourdummy is something"

Let me know whether this works as you wanted.

Regards,

Mihaela
#234614
Moderators: ForumSupporttomeperica
Time to create page: 0.064 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

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

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

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!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here