Skip to main content
Participant
January 30, 2024
Question

I have a JavaScript problem can someone help?

  • January 30, 2024
  • 3 replies
  • 335 views

I will explain what I need. I have two different checkboxes and I need everything to work depending on which one is checked. I also have another box where a date of some sort will be. Then I have the last box where I need the output. The output needs to be 20 or 26 months more than the date box depending on which checkbox is clicked. 

 

Check box names -- "Checkbox1" , "Checkbox1" (Checkbox1 is for men and Checkbox2 is for women)

Name of the date box -- "Date1" (date format is dd.mm.yyyy)

Output box name -- "Dateleaving"

 

For example, if "Checkbox1" is checked and the value of "Date1"= 26.01.2024, then "Dateleaving"=26.03.2026

 

If there are futher question let me know.

This topic has been closed for replies.

3 replies

Nesa Nurani
Community Expert
Community Expert
January 30, 2024

Use this as custom calculation script of "Dateleaving" field:

 

var cDate = this.getField("Date1").valueAsString;
var c1 = this.getField("Checkbox1").valueAsString;
var c2 = this.getField("Checkbox2").valueAsString;

if (cDate === "") 
 event.value = "";
else {
 var inputDate = util.scand("dd.mm.yyyy", cDate);
 if (c1 !== "Off"){
  inputDate.setMonth(inputDate.getMonth() + 20); 
  event.value = util.printd("dd.mm.yyyy", inputDate);}
 else if (c2 !== "Off"){
  inputDate.setMonth(inputDate.getMonth() + 26);
  event.value = util.printd("dd.mm.yyyy", inputDate);}
 else
  event.value = "";}

 

It would be a good idea to use radio buttons instead of checkboxes, or at least make checkboxes mutually exclusive.

kglad
Community Expert
Community Expert
January 30, 2024

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



<"moved from using the community">
Participant
January 30, 2024

Sorry "Checkbox2" got named incorectly