Form Help

TOPIC:

Adding criteria to a Switch action 1 year 8 months ago #255510

  • Topic Author
  • sitavs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
Hi,

I'm using your Action Script demo to show / hide a text box on selecting a radio button, there's a comment which says // here you can add further dependencies, but after trying several different ways I cannot work out how to add dependencies!

My radio group list contains: (example)
0;Yes;yes
0;No;no
0;On;on
0;Off;off
0;Other;

You'll note there is no value to 'Other'.

The code is:
function ff_Radioelem_action(element, action) //where radioelem is the name of the radio group
{
switch (action)
{
case 'change':
vals = '';
opts = JQuery("[name=\"ff_nm_Radioelem[]\"]");
for (o = 0; o < opts.length; o++)
if (opts[o].checked)
{
vals = opts[o].value;
}

if (vals=="yes") // here you can add further dependencies
{
bfToggleFields('off','section','sec3',bfDeactivateField);
}

else
{
bfToggleFields('on','section','sec3',bfDeactivateField);

}
break;
default:;
} // switch
} // ff_radioelem_action

In the bold field the value yes, when selected, will hide the text box. I would like the text box hidden when 'no', 'on', 'off' are selected.

The reason is that I need the text box to be visible only when 'other' is selected, but 'Other' has a label only (and not a value) so I cannot use:

if (vals=="other") // here you can add further dependencies
{
bfToggleFields('on','section','sec3',bfDeactivateField);
}

'Other' has no value so that the text in the text box is written to the database (using Integrator) and not the value.

Perhaps there is an easier way?

Thanks,
Simon

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

Adding criteria to a Switch action 1 year 8 months ago #255523

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

like this:
function ff_nameofradio_action(element, action) //where radioelem is the name of the radio group
{
switch (action)
{
case 'change':
vals = '';
opts = JQuery("[name=\"ff_nm_nameofradio[]\"]");
for (o = 0; o < opts.length; o++)
if (opts[o].checked)
{
vals = opts[o].value;
}

if (vals=="yes") // here you can add further dependencies
{
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}
else if(vals=='no') {
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}
else if(vals=='on') {
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}
else if(vals=='off') {
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}
else    
 {
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}
break;
default:;
} // switch
} // ff_nameofradio_action
Please replace nameofradio with name of your radio button group (not title)
In this bfToggkeFields (use on/off).
If you want to turn on/off section then instead of element use 'section' and 'nameofsection'
Like this:
bfToggleFields('off','section','nameofsection',bfDeactivateField);
-nameofelement is name of element which you want to turn on/off (not title)
-nameofsection is name of section which you want to turn on/off (not title)

-yes,no,off,on are values of radiobutton

-if someone select other this is code in this case:
else    
 {
bfToggleFields('off','element','nameofelement',bfDeactivateField);
}

I hope I explained it well :)

Let me know if you need more help

Regards,
Tihana

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

Adding criteria to a Switch action 1 year 8 months ago #255642

  • Topic Author
  • sitavs
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 30
  • Thanks: 0
That's perfect, thank you :)

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

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.045 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!