Reset form values on turn off

  • marino.brnardic
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 405
  • Karma: 9
  • Thank you received: 35

marino.brnardic replied the topic: Reset form values on turn off

Here's the script:
function ff_radio_action(element, action) //where radioelem is the name of the radio group
{
     switch (action)
     {
          case 'change':
          vals = '';
          opts = JQuery("[name=\"ff_nm_radio[]\"]");
          for (o = 0; o < opts.length; o++)
          if (opts[o].checked){
               vals = opts[o].value;
          }
          if (vals=="yes") // here you can add further dependencies
          {
            jQuery('[name="ff_nm_selectlist[]"]').prop('selectedIndex',0);
            return bfToggleFields('on','section','sec',bfDeactivateField);
          }
          else
          {
            return bfToggleFields('off','section','sec',bfDeactivateField);
          }
          break;
          default:;
     } // switch
} // ff_radioelem_action

The form is in the attachment. Let me know if you need help.

Regards,
Marino

File Attachment:

File Name: test_form_...14-2.zip
File Size:8 KB

Need to renew Pro Support?
Buy Here!
=========================================
Satisfied?
Consider a membership!
=========================================
Like us on Facebook
=========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
#203138
Attachments:
  • maxwbr
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0

maxwbr replied the topic: Reset form values on turn off

I am extremely grateful for the help, seriously, very much. But, unfortunately I do not think I was clear on my difficulty. I apologize.

I need to clear other fields based on a list. See attached image.

I select the value (red arrow). I need to clear the fields when I select another value (green arrow).

#203141
Attachments:
  • marino.brnardic
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 405
  • Karma: 9
  • Thank you received: 35

marino.brnardic replied the topic: Reset form values on turn off

Got it. Here's the script:
function ff_selectlist_action(element, action)
{
    switch (action) {
        case 'change':
        if(ff_getElementByName('selectlist').value == 'value3'){
           ff_getElementByName('textfield1').value = '';
           ff_getElementByName('textfield2').value = '';
           ff_getElementByName('textfield3').value = '';
           ff_getElementByName('textfield4').value = '';
        }
            break;
        default:;
    } // switch
} // ff_selectlist_action

The form is in the attachment. Let me know if this is the solution you need.

Regards,
Marino

Need to renew Pro Support?
Buy Here!
=========================================
Satisfied?
Consider a membership!
=========================================
Like us on Facebook
=========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
#203145
Attachments:
  • Posts: 16
  • Thank you received: 0

LaurieM replied the topic: Reset form values on turn off

Hi there!

Looks like this will do my job.

Would you please show me how to clear all form fields when value1, value2, value4, value5 and value6 are selected in the Select List.

That is: When a site visitor changes their mind about their choice from the select list, how do I clear fields already filled so that I don't get false info in the database?

Thanks,
Laurie.
#231893
  • Posts: 2734
  • Karma: 93
  • Thank you received: 369

mihaela replied the topic: Reset form values on turn off

Hello,

Here is how to achieve what you want.
Go Advanced properties of that select list element and in the Actionscript section set Type to Custom and Action to Change.

Then in code area below paste the following code:
function ff_selectlistname_action(element, action)
{
var tmp = ff_getElementByName('selectlistname').value;
eval('document.' ff_processor.form_id).reset();
ff_getElementByName('selectlistname').value = tmp;
} // ff_selectlistname_action
NOTE: In the code above replace every instance of selectlistname with the Name of that select list element.

Let me know whether this works as you wanted.

Regards,

Mihaela
#231900
  • Posts: 16
  • Thank you received: 0

LaurieM replied the topic: Reset form values on turn off

Hi Mihaela,

I'm not sure whether we're talking about the same thing, but the code you gave doesn't work for me.

Thanks for the quick response!

The code given in an earlier post works for value3. If I could duplicate this for the other values I'd be OK to go:

function ff_selectlist_action(element, action)
{
switch (action) {
case 'change':
if(ff_getElementByName('selectlist').value == 'value3'){
ff_getElementByName('textfield1').value = '';
ff_getElementByName('textfield2').value = '';
ff_getElementByName('textfield3').value = '';
ff_getElementByName('textfield4').value = '';
}
break;
default:;
} // switch
} // ff_selectlist_action

Is it possible to duplicate line 5, only with another value? Everything I've tried breaks the function of the code.

Note: I'm currently working with a basic test form where I have a select list with two options. Each option has conditionally two text fields.

When someone chooses option 1, fills in a field and then changes to option 2 to complete the form, the info in the field from option 1 remains and gives false info to the Database.

I need to clear all fields upon changing the choice in the select list.

Thanks,
Laurie.
#231911
Moderators: ForumSupporttomeperica
Time to create page: 0.223 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription 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 for just 49! (Summer Sale)

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

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