JS script doesn't work properly.

How to fix JavaScript errors when adding dynamic form inputs in ChronoForms.

Overview

The issue occurs because an outdated tutorial uses the MooTools JavaScript library, which is no longer supported in Joomla 3.
Use the built-in multiplier feature in ChronoForms v5 to add dynamic inputs, and for a maximum limit, either pre-add and hide elements or implement custom JavaScript.

Answered
mi mieszko 22 Aug, 2016
Hello,
I am trying to create a feature that adds additional form inputs after clicking a button. I am using this tutorial: https://www.chronoengine.com/faqs/58-cfv4/cfv4-elements-and-html/2700-how-can-i-have-a-button-to-add-more-form-inputs.html. I have done everything like in the article, but a JavaScript added in Load JS action doesn't work. When I test my form I see all 5 pairs of input and 4 buttons immediately.
Using a web inspector i see an error: "window.addEvent is not a function"
What am I doing wrong?
Thank you in advance for your help.
Gr GreyHead 23 Aug, 2016
Hi mieszko,

That is a CFv4 tutorial using the MooTools JavaScript library which is no longer supported in Joomla! 3.

ChronoForms v5 has both the ability to hide/show elements and to add copies of elements built in. What exactly do you need to do?

Bob
mi mieszko 23 Aug, 2016
I want to have a pair of form inputs and be able to add another pair by clicking a button. Of course up to a limit. Could you tell me where I can find it in new chronoforms?
mi mieszko 23 Aug, 2016
Thank you Bob!
This is exactly what I meant. But is there any option to set maximum number of added inputs? I cannot see it in multiplier settings.
Gr GreyHead 24 Aug, 2016
Hi mieszko,

Not built-in though you can do it with JavaScript.

If the maximum number is fairly small - say five or ten - then you could add them all to the form and hide all but the first. You can then use a button to un-hide the next one, or a drop-down to un-hide a fixed number.

Bob
mi mieszko 28 Aug, 2016
Thank you for your help Bob.
I have another problem with saving data from multiplier to database. I've done everything like in this FAQ: http://www.chronoengine.com/faqs/70-cfv5/5245-how-can-i-use-the-multiplier-in-cfv5.html but it still doesn't work. I have a warning: "Warning: Illegal string offset 'id' in /home/(...)/db_save/db_save.php on line 102".
I ma attaching some screenshots of my form settings:
JS script doesn't work properly. image 1

JS script doesn't work properly. image 2

JS script doesn't work properly. image 3

JS script doesn't work properly. image 4

JS script doesn't work properly. image 5
This topic is locked and no more replies can be posted.