I have got a field in a launch form called 'acc_date'. I have initialize the date on the event onnuload with nuSetDate('acc_date');
I would like to add a button to change the value of acc_date by adding 1 or more days. How can I do that ? Is there a nu JavaScript that is allowing me to perform this operation behind onclick event of the button ? Many thanks.
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Adding days to date field in a launch form
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Adding days to date field in a launch form
Add this function to the form's Custom Code:
And in the button's onclick event:
Code: Select all
function addDaysToDateObject(i, days) {
let o = $('#' + i);
let d = nuFORM.removeFormatting(o.val(), o.attr('data-nu-format'));
nuSetDateValue(i ,new Date(d).addDays(days));
}
Code: Select all
addDaysToDateObject('acc_date',4);
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: Adding days to date field in a launch form
Thanks Kevin. It works except that the value doesn't stay in the acc_date field. How to ensure that the field will keep the new value ?
Thx
Thx
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Adding days to date field in a launch form
Normally the value should stay in the field using the latest version.
Otherwise, add o.change(); after
nuSetDateValue(...)
Otherwise, add o.change(); after
nuSetDateValue(...)
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: Adding days to date field in a launch form
I have taken the last version yesterday.
o.change() doesn't change anything unfortunately.
If you have another idea...Thx
o.change() doesn't change anything unfortunately.
If you have another idea...Thx
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: Adding days to date field in a launch form
I think it is due to the nuFilter activated on change on this field.
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Adding days to date field in a launch form
I cannot replicate the issue here. If I understand it right, the object acc_date is on the main form and has an onchange event that refreshes the iframe
by calling nuFilterRun() ?
by calling nuFilterRun() ?
-
- Posts: 347
- Joined: Sun Mar 14, 2021 8:48 am
- Location: Geneva
- Has thanked: 94 times
- Been thanked: 12 times
Re: Adding days to date field in a launch form
That's correct Kevin. On change event, I execute the nuFilterRun(). When I click on the button on which I change the date, I see few seconds the new date but it disappears and become empty.
-
- nuBuilder Team
- Posts: 4562
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 528 times
- Contact:
Re: Adding days to date field in a launch form
It looks like your launch form is refreshed somehow. Are you calling nuGetBreadcrumb() somewhere?
I created a small demo (Launch form with date filter). Click on the [+] button to increment the date in the input and filter the iframe Browse form by that date. The date does not appear after the refresh.
https://test.nubuilder.cloud?f=61b75a13 ... t&p=nutest
You can inspect the objects, forms etc. and perhaps you can make out a difference.
I created a small demo (Launch form with date filter). Click on the [+] button to increment the date in the input and filter the iframe Browse form by that date. The date does not appear after the refresh.
https://test.nubuilder.cloud?f=61b75a13 ... t&p=nutest
You can inspect the objects, forms etc. and perhaps you can make out a difference.