TOPIC:

Reset form values on turn off 2 years 2 months ago #231932

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello,

I understand want to achieve.

Here is the code that will clear fields when select list is changed to any value, in this case any of values from value1 to value6.
function ff_selectlist_action(element, action)
{
    switch (action) {
        case 'change':
           ff_getElementByName('textfield1').value = '';
           ff_getElementByName('textfield2').value = '';
           ff_getElementByName('textfield3').value = '';
           ff_getElementByName('textfield4').value = '';
            break;
        default:;
    } // switch
} // ff_selectlist_action
The simplest way is to just omit the if statement. This script will be run each time the selected option in select list element is changed.

Let me know whether this works as wanted.

I thought that you have a possibly lengthy form and that you want that all form fields are cleared after the selected option in select list element is changed.

In that case the following code would do the trick:
function ff_selectlist_action(element, action)
{
    switch (action) {
        case 'change':
            var tmp = ff_getElementByName('selectlist').value;
            eval('document.'+ff_processor.form_id).reset();
            ff_getElementByName('selectlist').value = tmp;
            break;
        default:;
    } // switch
} // ff_selectlist_action
The following line of code would reset all form fields
eval('document.'+ff_processor.form_id).reset();
so it wouldn't be needed to reset each field individually like this:
ff_getElementByName('textfield1').value = '';
ff_getElementByName('textfield2').value = '';
ff_getElementByName('textfield3').value = '';
ff_getElementByName('textfield4').value = '';

I hope that you understand what I'm trying to explain.
I think in your case it is the simplest to use first solution.

Regards,

Mihaela

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

Reset form values on turn off 1 year 3 months ago #238164

  • LaurieM
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 16
  • Thanks: 0
Hi there!

Thanks for the help.

Using the first option in the previous post, with one level of conditional fields, I can clear the fields upon change of mind by the visitor.

However, I can't work out how the the js should go when I have nested conditional fields.

I have:

A select list with a name Division. It has 8 options (Programs).

Each Program has a conditional select list with 2 to 10 options, one of which in each case is Other.

If Other is selected in any of the second level select lists, then a conditional textfield, belonging to that program, opens.

The possible "change of mind" options are to change from Other to one of the listed programs or to change from one Division to another.

This is where I need to clear the Other fields.

Note: I'm js illiterate but have got my head around what's happening to some extent.

My problem seems to be working out what js code to put in the Action Script of which element and what values to include.

I'm hoping you can help me with either the way I've been trying to accomplish this or another way to get the same result, maybe using a Radiogroup for the second level.

Thanks,
Laurie.

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

Moderators: ForumSupport
Time to create page: 0.046 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!