=2016' work in this element?Thx!"> How to "show parent" field when selected value is >= some value? - Forums

Forums

How to "show parent" field when selected value is >= some value?

HerKle 17 Jun, 2019
Hi,
in a dropdown menu with an array of dynamically created years, I want to open a second field, if a year of the four recent years has been selected.
Unfortunately, the "events" section of "edit element" offers only '=' or '!='.
How can I make '>=2016' work in this element?
Thx!
GreyHead 17 Jun, 2019
Hi HerKle,

You could use four '=' events, or - maybe better - use custom JavaScript.

Bob
HerKle 17 Jun, 2019
Thanks Bob,
but the case is that with your idea next year I had to update the then new four recent years. I am searching for sth. automated like ">= date('Y')-4".
Unfortunately, I never worked with JavaScript (which I learned can be deactivated by the user so that forms won't work properly).
Too bad. :-(
Herbert
healyhatman 17 Jun, 2019
ANYTHING you use on the front end can be deactivated by the user, and those form events you're talking about are still based on Javascript. You would need a javascript function on the front end (views), and a PHP check on the backend (actions), and for both of those you can dynamically set the year based on the current year.
HerKle 17 Jun, 2019
Well, healyhatman, as said, I never worked with JavaScript. So I have not the slightest idea how to create the javascript function, you are talking about. But thx anyway.
Herbert
healyhatman 17 Jun, 2019
Well you can use = in the field events, with 4 values each on a ddiffernt line.
{date:Y$today -1 year)}

But that only works if your field is year only. Otherwise it's 2am so you're on your own for a bunch of hours
HerKle 18 Jun, 2019
Thx healyhatman,
{date:Y$today -1 year)}
I haven't seen this syntax yet, I am prepared to try it, but you have a closing bracket, which were nowhere opened - and I don't know where to put it.
Herbert
healyhatman 18 Jun, 2019
Gey rid of the closing ) it's not supposed to be there
HerKle 18 Jun, 2019
I tried in Element Settings > Events:
First event: On '=' {date:Y$today -1 year} 'show parent' 'nextfield'
Second event: On '!=' {date:Y$today -1 year} 'hide parent' 'nextfield'.

The nextfield isn't shown at all - even when I select '2018' from my years' field. :-(
healyhatman 18 Jun, 2019
Sorry. {date:Y$-1 year}

Again though this only works if your field is year only.
HerKle 19 Jun, 2019
Sorry, this doesn't work either.
My field "year" is 'year only' but the third field within a multi-field construct.
Might that be a reason for malfunction (although each of the fields has its own event section)?
Thx. Herbert
healyhatman 19 Jun, 2019
Ahh well worth a try. Looks like you'll have to program it yourself. The actual value is stored in a hidden field after the visible field.

Post a screenshot of your field event just in case though
HerKle 19 Jun, 2019
I get "Error saving the attachment file" with 640px wide and 38 kb sized jpg file, when trying to upload the screenshots. This forum is strange. Is it better working with other browsers than latest Firefox?
healyhatman 19 Jun, 2019
Try using snag.gy there is a problem with the forums right now
HerKle 19 Jun, 2019
Dropdown field "Years" loading data dynamically:
https://snag.gy/aQkKlD.jpg

Dropdown Events:
https://snag.gy/GWeU5I.jpg
healyhatman 19 Jun, 2019
And once again I failed to see the Chronoforms v5 tag. Ignore everything I've said, it's all for V6 and none of it works on the obsolete v5.

You'll have to do it all manually with JavaScript and I can't help you, only Bob does the old v5 stuff.
HerKle 19 Jun, 2019
I would have purchased v6 since long - if only the payment methods weren't limited to credit card or paypal - neither of which I can use.
healyhatman 19 Jun, 2019
What payment method CAN you use?
HerKle 19 Jun, 2019
In Europe it's also common to pay immediately from your bank account via a direct payment service, eg. Klarna.com.
IBAN and BIC of the vendor must be available.
healyhatman 19 Jun, 2019
Well then maybe Max will integrate my Mollie payment plugin on his payment page ?
This topic is locked and no more replies can be posted.