TOPIC:

Problem with bfToggleFields? 8 months 14 hours ago #266927

  • Topic Author
  • admin@horshamu3a.org.uk
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 62
  • Thanks: 0
Is there an issue with bfToggleFields?
I have boiled the functionality down to a simple form with 2 fields - text field txtText and and checkbox chkText.
Using the code
function ff_chkTest_action(element, action)
{
    switch (action) {
        case 'change':
if (ff_getElementByName('chkTest').checked)  {
alert(ff_getElementByName('chkTest').checked);
               return bfToggleFields('on','element','txtTest',bfDeactivateField);
          } else {
               return bfToggleFields('off','element','txtTest',bfDeactivateField);
          }
            break;
        default:;
    } // switch
} // ff_chkTest_action
I get the alert, so the code's valid, but can't get the txtTest field to disappear/reappear.

Nothing is appearing in error.log.
I'm using Joomla 3.9.23, & PHP8.
I expect it's smth obvious, but can't see what.

Please Log in or Create an account to join the conversation.

Problem with bfToggleFields? 7 months 4 weeks ago #266930

  • Mirec's Avatar
  • Mirec
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 2952
  • Karma: 2
  • Thanks: 150
Hi,

I have one question, did you define the dummy visibility rule in Advance of element "checkbox ", like this:
 turn on element mydummy if yourdummy is something

In this link below is explained how to use visible rules:

crosstec.org/en/support/online-documenta...s-in-javascript.html

If you have more questions, feel free to ask!
Reagrds,
Mirko

Please Log in or Create an account to join the conversation.

Last edit: Post by Mirec.

Problem with bfToggleFields? 7 months 4 weeks ago #266982

  • Topic Author
  • admin@horshamu3a.org.uk
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 62
  • Thanks: 0
That worked, thanks. In the live form, I have some "turn on element ... if ... is ..." statements, so it is not required.
In the live form, I have 2 bfToggleFields calls, one after another, but the second field doesn't show/hide. No code after the first bfToggleField executes.
switch (action) {
        case 'change':
              if (ff_getElementByName('chkAddMem').checked)  {
alert('A');
                     return bfToggleFields('on','element','txtFName2',bfDeactivateField);
alert('B');
                     return bfToggleFields('on','element','txtLName2',bfDeactivateField);
              } else {
                    return bfToggleFields('off','element','txtFName2',bfDeactivateField);
                    return bfToggleFields('off','element','txtLName2',bfDeactivateField);
              }
            break;
BF BreezingForms 1.9.1 Stable (build 941)
Joomla 3.9.23
PHP8
Chrome Version 96.0.4664.93 (Official Build) (64-bit)

You do not have permissions to access this page.

Please Log in or Create an account to join the conversation.

Problem with bfToggleFields? 7 months 4 weeks ago #266983

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10737
  • Karma: 3
  • Thanks: 718
Hi,

please try like this:
switch (action) {
        case 'change':
              if (ff_getElementByName('chkAddMem').checked)  {
alert('A');
                      bfToggleFields('on','element','txtFName2',bfDeactivateField);
alert('B');
                      bfToggleFields('on','element','txtLName2',bfDeactivateField);
              } else {
                     bfToggleFields('off','element','txtFName2',bfDeactivateField);
                   bfToggleFields('off','element','txtLName2',bfDeactivateField);
              }
            break;

In this case use it without return :)

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Problem with bfToggleFields? 7 months 4 weeks ago #266995

  • Topic Author
  • admin@horshamu3a.org.uk
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 62
  • Thanks: 0
Thanks, that worked fine.
Why is the return in the example? Confusing!

Please Log in or Create an account to join the conversation.

Problem with bfToggleFields? 7 months 4 weeks ago #266996

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 10737
  • Karma: 3
  • Thanks: 718
Hi,

because it is only one condition, but when there are more conditions then only first condition will be executed.
Also, if you have only one condition you can use it without return too.

I hope I am not confuse you :)

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.051 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

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!