× Form Help

Joining visible elements

  • ante
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 61
  • Thank you received: 0

ante created the topic: Joining visible elements

Hi

I have a set of Select from List elements. Some of the element have a dependency of one of the previous elements.
For instance: Element1 is the mother of element 2-5. If I pick value A in Element1, then Element2 will be visible, and if value in Element1 is B then Element3 will be visible and so on.

At the bottom I have a Text-field which should be auto-populated by the values from each of the previous elements. I have done this half successful by using "Initialization Script" under more options.
My string looks:
function ff_MySuperForm_init()
{
 setInterval(calc, 500);
 setInterval(sum, 500);
} // ff_MySuperForm_init

function calc() {
ff_getElementByName("MySumField").value = "Summary" + ff_getElementByName("Element1").value + "_" + ff_getElementByName("Element2").value + ff_getElementByName("Element3").value + ff_getElementByName("Element4").value +  ff_getElementByName("Element5").value;
}

This works, but issue is if I first pick Value A in Element1 then Element2 is visible. I now pick a value in Element2 which will now also be added to MySumField. I then Go back to Element1 and change the value from A to B. This will hide Element2 and instead show Element3 where I pick a new value. Issue is that the value that I have already picked in Element2 is still in MySumField together with the new value from Element3.
Is there a way to not show or include the value for elements that are not active.

Worth mentioning is that each Element has a "Pick Option" as first option which will give no value (0;Pick Option;). Maybe this can be used in solution? I am thinking if I happen to also add a hidden field in the future that I would like to include in the MySumField.

Hope I did not explain it to complicated :-) :laugh:

Best regards,
Ante
#234242
  • Posts: 3124
  • Karma: 104
  • Thank you received: 410

mihaela replied the topic: Joining visible elements

Hello,

The solution to this is the same as suggested in this topic crosstec.org/en/forums/15-usage/125908-o...lds-are-visible.html .

If you clear the fields that are hidden, then value of that fields will be "" and in the "MySumField" only fields visible at the moment of submitting will be included.

Since you already have Initialization script, you could put the code in initialization script.

Here is an example how to set select list value to first option:
if(  ff_getElementByName('Element1').value == "A") {
ff_getElementByName('Element3').selectedIndex= 0; }

Let me know whether you've managed to make it work for your form as you wanted.

Regards,

Mihaela
#234255
  • ante
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 61
  • Thank you received: 0

ante replied the topic: Joining visible elements

Hello Mihaela

Thank you. I did not get it to work with Initalization script for the form, but I finally manged to do it with Action Script for each mother element. My solution is rather complex with Element dependencies going in a matrix, but finally goal is reached :-)

Thanks

Best,
Ante
#234276
  • Posts: 3124
  • Karma: 104
  • Thank you received: 410

mihaela replied the topic: Joining visible elements

Hello again,

I'm glad that in the end you have managed to make it to work.

Regards,

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