• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

If date element is not null then change another element to 3rd Dropdown selection

Bren

Member
Hello all.
I have a form with a date element that if a date is added then the user should also change the Dropdown element beside it to the 3rd drop down value. The user should do this every time; but the user forgets. So, it would be nice if during form submission or when the user selected the date that this automatically happens. My 1st thought was that maybe some JS in the date element would work or maybe during the form submission...
Regardless, I?m not sure what JS code to use (I haven?t used either option, yet). Any suggestions?
Thanks in advance.
 
Try putting a JS event on the date element, on 'change' ...

this.form.formElements.get('yourtable___yourdropdown').update('x');

... which x is the value of the dropdown option you want to select. So not '3' (for third), but the actual value of the third option.

-- hugh
 
I just tried your suggestion and it works perfectly. Thank you, Hugh.
One more question. It would be even cooler if the user selected this particular Dropdown element item and the date element (if empty) changed to today's date. Could I trouble you for your suggested JS to put within the Dropdown element to make this happen?
Thanks in advance.
 
Use on 'click' (maybe 'change', but I think that doesn't work for dropdowns in some browsers).

Code:
if (this.getValue() == '3') {
   var date = new Date();
   this.form.formElements.get('yourtable___yourdate').update(date.format('%Y-%m-%d'));
}

Replace '3' with the value you want, and yourtable___yourdate with date element name.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top