howto reset data inside a Section via a select-group

  • rd
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 60
  • Thank you received: 2

rd created the topic: howto reset data inside a Section via a select-group

we have an order form that has several sections, each with data to fill out (eg, text-fields, radio-groups, etc).
Some of these sections are conditional:

Example:

does something exist: Yes or No
If no don't show show section
If Yes show it and let the user fill out the section.

And here is my question:
If the user changes its mind and decides No after he filled out the section, and he hits the No-Button, is there any way resetting the previously filled out section and set all values to there initial state?

Thank you very much
Rolf
#233392
  • Posts: 2147
  • Karma: 75
  • Thank you received: 277

mihaela replied the topic: howto reset data inside a Section via a select-group

Hello,

Yes, it is possible to reset the fields if user changes his mind.

To make the form work the way you want you have to write an Actionscript code for that select list element.

Navigate to Advanced properties of the radio group element with yes or no option if something exists. In the Actionscript section set Type to Custom and Action to Change.
Then in the code area below put code similar to this:
function ff_radiogroupname_action(element, action)
{
   if(jQuery('[name="ff_nm_radiogroupname[]"]:checked').val()  == "no") { 
  ff_getElementByName('field1').value = "";
  ff_getElementByName('field2').value = "";
   }
} // ff_radiogroupname_action
NOTE: This way you can reset the values for most fields.

Also, I assumed that element for deciding "does something exist: Yes or No" is a radio group. If it is different type of element the code is a bit different.

Let me know whether this helped.

If you have more questions, feel free to ask.

Regards,

Mihaela
#233393
  • rd
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 60
  • Thank you received: 2

rd replied the topic: howto reset data inside a Section via a select-group

Thank you Mihaela for your offer to ask.
I really appreceate your help.

Unfortunately it is not working. I must admit, I am not familiar with scripting. So very likely I am making some mistakes. Here is what I have done so far:
  1. I created a testform with one page
  2. beneath the form I created an element type radiogroup named Switch_SectionWithData. The definition for this radio group is
    0;Yes;yes
    1;No;no.
    On the advanced tab I filled in the code. I pressed the button "Code Framework erzeugen" (Sorry, don't not how this is in english, I am using the german version) and changed the code accordingly:
    function ff_Switch_SectionWithData_ac [attachment=20526]form.jpg[/attachment] [attachment=20527]switch_scripting.jpg[/attachment] [attachment=20526]form.jpg[/attachment] [attachment=20527]switch_scripting.jpg[/attachment]tion(element, action)
    {
       if(jQuery('[name="ff_nm_radiogroupname[Switch_SectionWithData]"]:checked').val()  == "no") 
    { 
      ff_getElementByName('mytext').value = "0";
      ff_getElementByName('checkbox').value = "0";
      ff_getElementByName('radiogroup').value = "0";
      ff_getElementByName('fileupload').value = "0";
       }
    } // ff_Switch_SectionWithData_action
  3. on the same level as the radiogroup I created a section named SectionWithData. I set this section to "Hide"
  4. Below this section I created a textfield named mytext, a checkbox name checkbox, a radiogroup name radiogroup and a fileupload named fileupload.
  5. in the advaced properties of the form I added the following rules:
    turn on section SectionWithData if Switch_SectionWithData is yes
    turn off section SectionWithData if Switch_SectionWithData is no
The rules are working. The section can be turned visible or invisible by pressing yes or no on the radiogroup. But none of the elements are being reseted after I changed something and pressing no and yes again. On yes all entries are still there.

Please, could you provide a more detailed explanation?

Again, thank you very much
Regards
Rolf

ps. by the way: the preview isn't working here in the editor. Hope my formatting turns out right ;-)
#233400
Attachments:
  • Posts: 2147
  • Karma: 75
  • Thank you received: 277

mihaela replied the topic: howto reset data inside a Section via a select-group

Hello,

I see what is causing this not to work.

In this if statement you have put the following condition:
if(jQuery('[name="ff_nm_radiogroupname[Switch_SectionWithData]"]:checked').val()  == "no")

while it should be:
if(jQuery('[name="ff_nm_Switch_SectionWithData[]"]:checked').val()  == "no")

Also, of assigning values only this will work:
ff_getElementByName('mytext').value = "0";
Checkbox and radio group values can't be assigned that way. Furthermore, a number "0" can't be assigned to file upload value.

Therefore, you can use this code:
ff_getElementByName('mytext').value = "0";
ff_getElementByName('fileupload').value = "";

To uncheck the checkbox this piece of code is needed:
ff_getElementByName('checkbox').checked = false;

If you want to uncheck all radio group options, use this code:
jQuery('[name="ff_nm_radiogroup[]"]:checked').prop("checked", false);

Let me know whether you've managed to apply this to your form and whether this worked as you wanted.

Regards,

Mihaela
#233415
The following user(s) said Thank You: rd
  • rd
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 60
  • Thank you received: 2

rd replied the topic: howto reset data inside a Section via a select-group

Hello Mihaela,

it is working!
Thank you very much.

Regards
Rolf
#233444
  • Posts: 2147
  • Karma: 75
  • Thank you received: 277

mihaela replied the topic: howto reset data inside a Section via a select-group

Hello,

I'm glad that it is working as you wanted now.

Regards,

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