Expand my Community achievements bar.

simple scripting help with Designer?

Avatar

Former Community Member
I'm using Designer to make some simple forms for my company.

For the most part it's just layout stuff, but I have a need for some scripting and have zero experience with this.

I want to allow the user to enter a date into a field (The delivery date for a product), and then have a number of other fields automatically generate dates based on the one entered, in order to create a workback schedule. The dates generated will be, for example, 3 weeks prior to the date entered, 7 weeks, 8 weeks, etc.

I've started to look at FormCalc to do this but do not know the language and I'm finding it daunting.

Perhaps this is a very straightforward script?

Any help would be greatly appreciated.

Thanks,

Jon
5 Replies

Avatar

Former Community Member
J.



The script is simple if you talk script. I dont but I have (last night) just encountered a similar issue.



I wanted to select a date and have the form generate future dates. 4, 8 12 months etcetera in a table.



If you havent solved your problem or gotten professional help let me know and I can suggest possible solutions.



I cant right now cos its not in my head. :)

Avatar

Former Community Member
I ended up using this JavaScript code to add a user-defined number of years to a user-defined date:



var execDate = myDateField.rawValue;



//tell JS that years is a number

yearsToAdd = yearsToAdd * 1;



//convert to JS format

execDate = execDate.replace(/-/g,"/");

var termDate = new Date(execDate);



//add years and subtract one day

termDate.setFullYear(termDate.getFullYear() + yearsToAdd);

termDate.setDate(termDate.getDate() - 1);



//insert the date

myTargetDateField.formattedValue = util.printd("mmmm d, yyyy", termDate);



also see this thread http://www.adobeforums.com/cgi-bin/webx/.3bc20e91/0

Avatar

Former Community Member
Hi,



You should be able to use the following code in FormCalc to do what you want:



(Adds 9 days to the date entered by a User.)

date1.rawValue = Num2Date(Date2Num(date2.rawValue, "MMDDYYYY") + 9);



This would go in the Exit Event of date1, and users must match the entry format that you specify in the Date 1 Date/Time Field.



I hope this helps.