Answered
I can't find a straight answer to this simple Acrobat JavaScript question through standard search (you try Googling "and"!), so I'm coming to the forum for help:
If I need two things to be true in an IF statement, what's the proper way in Acrobat JavaScript to form the .and.?
For example, here's the statement:
If Field_4E=100 .and. Field_4F<45, Field_4G="O"
Here's what I've tried in JavaScript based on what I've found online, but it doesn't seem to work:
var o4E = this.getField("4E");
var o4F = this.getField("4F");
var o4G = this.getField("4G");
if (o4E.value = 100 & o4F.value < 45) {
o4G.value = "O";
}
Any help would be greatly appreciated!
Donna
// Get first two field values,
// and convert to numbers using + operator
var o4E = +getField("4E").value;
var o4F = +getField("4F").value;
// Get field object
var o4G = getField("4G");
if (o4E == 100 && o4F < 45) {
o4G.value = "O";
}
Where exactly do you want to place this code? Also, you should probably have an "else" clause in there to set the value of the "04G" field to something if those conditions are not met:
if (o4E == 100 && o4F < 45) {
o4G.value = "O";
} else {
o4G.value = "Something else";
}
George