TOPIC:

Clear value of all elements in a section? 2 months 3 weeks ago #272263

  • Topic Author
  • jdwires
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
I have a sports camp form with multiple fieldset sections. Each section is for a single camper. I have a set of buttons that "add camper" and "remove camper" that will show or hide the sections. Part of the action script on my "remove camper" will hide the last visible section as well as empty the values of any element in that section using the ff_getElementByName() function to set an empty value as shown below.
ff_getElementByName("name" + sectionCount).value = "";
ff_getElementByName("position" + sectionCount).value = "";
ff_getElementByName("school" + sectionCount).value = "";
ff_getElementByName("grade" + sectionCount).value = "";

Is there a better way to clear the values of a section? Or is there a way to target all of the elements within a section? Maybe something like:
ff_getSection('sectionNameHere').eachElement(){//do stuff to each element here}

Does this sort of thing exist? I found where the ff_getElementByName() function in the facileform.process.php seems to be defined, but that file didn't have anything about sections in it. :(

P.S. I found a couple of other functions in that file that I didn't realize exists. Are there any examples or documentation of the ff_getDivByName(), ff_getPageByName(), ff_getIdByName(), and ff_getForm() functions?

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

Clear value of all elements in a section? 2 months 3 weeks ago #272264

  • Topic Author
  • jdwires
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
Admin, I accidently selected the wrong forum category. Should be under the BreezingForms questions.

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

Last edit: Post by jdwires.

Clear value of all elements in a section? 2 months 3 weeks ago #272265

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

this is ok, we see all category :)

About your problem, you want on click on button clear elements in sections, then for this you can use javascript and visibility rules.
For this you must put this in form->Advanced->Visibility rules:
 turn on element mydummy if yourdummy is something
Don't change this, leave it as it.

Then go on this custom button->Advanced->Actionscript->check click and add:
function ff_nameofhidebutton_action(element, action) 
{
     switch (action)
     {
          case 'click':
          
              bfToggleFields('off','section','nameofsection',bfDeactivateField);
              ff_getElementByName('nameofelement').value='';
              ff_getElementByName('nameofsecondelement').value='';
          
          
          break;
          default:;
     } // switch
} // ff_nameofhidebutton_action
Please replace:
nameofhidebutton with name of your button for hide (not title)
nameofsection with name of section (not title)
nameofelement with name of element(s) (not title)

I hope I explain it well

If you need more help, let me know

Regards,
Tihana

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

Clear value of all elements in a section? 2 months 3 weeks ago #272272

  • Topic Author
  • jdwires
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
Okay. That is essentially the same as what I have in my ActionScript for the button. I was just wondering if there was a better way to clear the values in the section without specifically calling each one by name. It's not a big deal with only four elements in the section, I was wondering about if I had a lot more elements.

What about mixing jQuery and the FF scripts and use the jquery each() function and the FF reset() each input value within the fieldset? Maybe something like:
$('#removeButton').click(function(){
    bfToggleFields('off','section','nameofsection',bfDeactivateField);
    $('#section1 input').each(function(){
        $this.reset();
    })
});

I realize this would only target text inputs but do you think it would work?

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

Clear value of all elements in a section? 2 months 3 weeks ago #272276

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

I didn't test it but something like this in form->Advanced->More options->Scripts->Initialization script->check Custom and put:
function ff_nameofform_init()
{
setInterval('test()', 500);
} // ff_nameofform_init

function test() {
 jQuery('[name="ff_nm_nameofremovebutton[]"]').click(function(){
  bfToggleFields('off','section','nameofsection',bfDeactivateField);
jQuery('#bfQuickModeSection44 input').each(function() {
 jQuery(this).reset();
});

  });
}
Please replace:
-nameofform with name of your form (not title)
-nameofremovebutton with name of button for remove (not title)
-nameofsection with name of section (not title)
-bfQuickModeSection44 with ID of your section, you can find it with right click to your browser->Inpsect->and in Console find ID for this section

Hope this helps

Regards,
Tihana
The following user(s) said Thank You: jdwires

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

Clear value of all elements in a section? 2 months 3 weeks ago #272305

  • Topic Author
  • jdwires
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 0
Excellent! I thought I might be on the right track but wasn't sure. I'll give it a try the next time I do a form like this.

Thanks,
Joel

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

  • Page:
  • 1
  • 2
Time to create page: 0.041 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!