Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Click event to add (or subtract) a day to a date field

Avatar

Level 4

I have a form that is giving me a little trouble. I want to be able to input a start date in one field, then input a number of days in another field, and then have it calculate a date that is that number of days away from the start date. The form is actually working ok for the most part, but there are a couple of issues I'm having.

1. The end date is not calculating immediately upon exiting the number of days field. You have to tab all the way back to the start date and only when you exit that field does it calculate the end date. I need it to calculate when you exit the number of days field.

2. I have added a little (+) and (-) button to be able to increase or decrease the date by one day. This works, but the problem is, I want to do this in the background. Meaning, I want the calculated date to change, but the # of days field to not change.

So say I enter 12/1/2010 in the start date. Then I enter 1 in the # of days field. When I tab to the Calculated date field, it should immediately change to 12/2/2010. Then, if I click (+), the Calculated date field should go up to 12/3/2010, but the # of days field should stay at 1.

I've uploaded a sample of what I have figured out so far here:

https://acrobat.com/#d=v4c4KKdj0hesicxO8yO1pw

Thanks so much for any help I can get on this!

Jo

1 Accepted Solution

Avatar

Correct answer by
Level 10

I think this is what you are after. I moved the logic to the calculate event of the target date and added a numeric field to hold the result of adding/subtracting (called 'delta').

// form1.#subform[0].date2::calculate - (FormCalc, client)

var date1 = Date2Num(date1.formattedValue,"MM/DD/YYYY")

$.rawValue = Num2Date(date1+days+delta,"MM/DD/YYYY")

Untitled.png

You could make 'delta' hidden.

Steve

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

I think this is what you are after. I moved the logic to the calculate event of the target date and added a numeric field to hold the result of adding/subtracting (called 'delta').

// form1.#subform[0].date2::calculate - (FormCalc, client)

var date1 = Date2Num(date1.formattedValue,"MM/DD/YYYY")

$.rawValue = Num2Date(date1+days+delta,"MM/DD/YYYY")

Untitled.png

You could make 'delta' hidden.

Steve

Avatar

Level 4

Perfect!! Thank you so much! I didn't think of having it add the extra days in a separate field...I have to learn how to think more on the outside of the box.

Thanks for your help!

Jo