BF switch to page, based on element value

  • Gilles361
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 153
  • Thank you received: 4

Gilles361 created the topic: BF switch to page, based on element value

Hi,

I've create Page 1, Section 1, an element list (Categorie). I would like to switch to a specific page base on element values (Categorie)... when I click on NEXT Button

I've created an Submit button (NEXT) with ACTION / Click, with custom code (found on your site), but not working with my Element value "Characters" or numbers. Please find my (beginner coding) ... below :

function ff_BoutonCategorie_action(element, action)
{
switch(ff_getElementByName('Categorie').value )
{
case 'Seniors': ff_switchpage(3);
break;
case 'Juniors': ff_switchpage(4);
break;
case 'Departementaux': ff_switchpage(5);
break;
} break;
default:;
} // ff_BoutonCategorie_action

OR ANOTHER CODE (using a variable)

function ff_BoutonCategorie_action(element, action) {
$categorie = ff_getElementByName('Categorie').value;
switch ($categorie) {
case 'Seniors': ff_switchpage(3); break;
case 'Juniors': ff_switchpage(4); break;
case 'Departementaux': ff_switchpage(5); break;
default:; break;
}
} // ff_BoutonCategorie_action

Could you help me to do so?
Is my code wrong?
Can I switch from Element value?

Thanks, Gil
#234305
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: BF switch to page, based on element value

Hello,

The second code that you have tried to use won't work because you have defined a variable as in PHP, while Actionscript code should be written in JavaScript.

As for the first code, I have tried to recreate what you want to achieve and used this code very similar to yours:
function ff_BoutonCategorie_action(element, action)
{
    switch (ff_getElementByName('Categorie').value) {
        case 'Seniors':
ff_switchpage(3);
break;
    case 'Juniors':
ff_switchpage(4);
break;
    case 'Departementaux':
ff_switchpage(5);
break;
        default:;
    } // switch
} // ff_BoutonCategorie_action

This code worked. I see that in your code you have misplaced one closing bracket "}" and have an extra "break" so I assume that is the reason why it is not working for you.

Please add the missing bracket at the right place and remove unnecessary break statement and let me know whether it works after you do so. You can simply compy my code.

Regards,

Mihaela
#234309
  • Gilles361
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 153
  • Thank you received: 4

Gilles361 replied the topic: BF switch to page, based on element value

Hi,
Thanks for your code, I've understood it, but I can't have it working...
What ever is my selection "Categorie", it goes to fist "radio button" (Page) in the list (Junior)..
I've attached my TEST Form (sorry some french inside)

Thanks, Gil
#234368
Attachments:
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: BF switch to page, based on element value

Hello again,

Now I realize where is the problem.

You have a radio group element "Categorie" and since in your first message you have written "I've create Page 1, Section 1, an element list (Categorie)."

The reason why this is not working is that
ff_getElementByName('Categorie').value
fetches value selected in a select list, but not the value form radio group.

You can fetch the value selected in a Radio group like this:
jQuery('[name="ff_nm_Categorie[]"]:checked').val()

The whole code should look like this:
function ff_BoutonCategorie_action(element, action)
{
    switch ( jQuery('[name="ff_nm_Categorie[]"]:checked').val() ) {
     case 'Seniors':
ff_switchpage(4);
break;
    case 'Juniors':
ff_switchpage(3);
break;
    case 'Departementaux':
ff_switchpage(5);
break;
        default:
ff_switchpage(7);
break;
    } // switch
} // ff_BoutonCategorie_action

Let me know whether it works after you change it.

Regards,

Mihaela
#234381
  • Gilles361
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 153
  • Thank you received: 4

Gilles361 replied the topic: BF switch to page, based on element value

Hi,
Thks.
Now, selection Switch (case..) works ok with radio buttons, after fetches.
But, after page 4 (example), I just go to Submit page 7, Forms requests all others pages REQUIRED values to be answered... So many error messages.

How to fix this behavior?
Thanks, Gil
#234406
  • Posts: 1933
  • Karma: 67
  • Thank you received: 234

mihaela replied the topic: BF switch to page, based on element value

Hello again,

I understand the problem.

That can be solved using some code.

What you should do is you should add a piece of code to every button which switches to page 4 for example, to turn off all elements on other pages that are required.

If this elements are turned off then when you click submit this fields will no loner be required.

You can either turn element by element like this:
bfToggleFields('off', 'element', 'elementname', bfDeactivateField);
or you can turn off the whole sections like this:
bfToggleFields('off', 'section', 'sectionname', bfDeactivateField);

Let me know whether you have managed to make it work.

Regards,

Mihaela
#234428
Moderators: ForumSupporttomeperica
Time to create page: 0.077 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