Copy link to clipboard
Copied
Not sure what I am doing wrong here, but I think I am close. I am trying to have a function find the smaller of either one field entered by the user of the form or another set of numbers based on a dropdown menu.
I am not sure where I am going wrong here, I think I am using the switch function incorrectly to assign a value to one of my variables, but I have no idea how to fix it:
var z = this.getField ("Line1");
var y = this.getField ("Dropdown3").value;
var x = (function(y) {
switch(y) {
case "S":
x = 39375
break;
case "MFJ":
x = 78750
break;
case "MFS":
x = 39375
break;
case "HH":
x = 52750
break;
}
})
event.value = Math.min(z.value, x.value);
this.getField ("Line11")=event.value;
The cases are the different values of the dropdown. That notation has worked in other fields, but I have never tried to use it to assign a value to a variable, only to find the output of a field. Line1 is a field where a user enters a number.
What am I doing wrong? I am not very well versed in javascript.
Try this:
var z = this.getField ("Line1");
var y = this.getField ("Dropdown3").value;
var x = 0;
switch(y) {
case "S":
x = 39375;
break;
case "MFJ":
x = 78750;
break;
case "MFS":
x = 39375;
break;
case "HH":
x = 52750;
break;
}
event.value = Math.min(z.value, x);
Copy link to clipboard
Copied
Try this:
var z = this.getField ("Line1");
var y = this.getField ("Dropdown3").value;
var x = 0;
switch(y) {
case "S":
x = 39375;
break;
case "MFJ":
x = 78750;
break;
case "MFS":
x = 39375;
break;
case "HH":
x = 52750;
break;
}
event.value = Math.min(z.value, x);
Copy link to clipboard
Copied
That worked, thank you!
Why do you have to define var x as 0 first if you don't mind me asking?
Copy link to clipboard
Copied
When you want you can remove the zero.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more