How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Chris Baxter Your Own Question

Chris Baxter
Chris Baxter, Programming Tutor
Category: Programming
Satisfied Customers: 246
Experience:  Completed BSIT concentration Software Engineering, tutored other students and classmates in Java and, C++, and Obj C.
Type Your Programming Question Here...
Chris Baxter is online now
A new question is answered every 9 seconds

I am creating a custom calculation script in adobe form

Customer Question

I am creating a custom calculation script in adobe for a form field to calculate +14 days from "today". I have the form correctly auto populating on opening todays day. Heres where it gets whacky. The customer wants a drop down menu with 2 options. Today +14 and Today +180. I cant get it to work with only 1 (+14) nut not both. OR is there a script i can run where the user enters the # ***** days (14 0r 180) and another field enters the correct date?
(function () {
// Get date from field
var v = getField("Today").value;
if (v) {
// Convert string to date
var d = util.scand('mm/dd/yyyy', v);
// Add 180 days
d.setDate(d.getDate() + 180);
event.value = util.printd("mm/dd/yyyy", d);
} else {
// Blank field if no date entered
event.value = "";
Submitted: 1 year ago.
Category: Programming
Expert:  Chris Baxter replied 1 year ago.


That code would take the following format:

var match = 'match3';


case 'match1': // break;

case 'match2': // do stuff here break;

case 'match3': console.log('test complete'); break; default: // do this if all else fails break;


Where the first variable "match3" = user selection from drop down **everything after "//" is comment

Switch(match) where match is the menu

{ <<dont forget these!

and each of the cases is a different menu selection, where code continues the run on the match and ignores the other switches. A lot like your }ELSE{ though in this case your calculate could be contained in the switch as the beginning of the code to be run.

Customer: replied 1 year ago.
am i adding this code or replacing what I have, i dont see how this is calculating a date + 14 and +180 days to a menu item on the drop down.
Expert:  Chris Baxter replied 1 year ago.

You are writing a code, if you want someone to write it for you it will be an additional charge. (Typically $50 USD is about average for most of the programmers here.) As for the code I gave, it is an example, in your code, you would want to put the "TODO" math after each of the case switches, yes repeat it. One case per menu selection, so your menu has two options +14 and +180

If your date field is filled in before the case (menu choice) is made, then EVERYTHING you currently have gets dropped down under a case. By choosing a choice in the menu, the user chooses which direction the program run will take. Case 1 = +14 calculate and display result, end program. Case 2= +180 calculate and display result, end program.

So everything var v onward and short of the final closing brackets gets contained in a case statement. The second statement is a copy of all this again, but with the changes for math.