Copy link to clipboard
Copied
First of all it really sucks being ignorant. BUT, I am really grateful for the help offered here, so Thank You!!
I have created two Document Javascripts with an array of field names.
Here is one...
function AddGPM()
{
// Set up an array of field names
var aNames = ["N36", "N37", "N38", "N39",
"N40", "N41", "N42", "N43",
"N44", "N45", "N46", "N47",
"N48", "N49", "N50", "N51",
"N52", "N53", "N54", "N55"];
// Set up an object that will be returned
var oValsGPM = {};
// Loop through the field names and add name/value pairs to the object
for (var i = 0; i < aNames.length; i += 1) {
oValsGPM[aNames] = getField(aNames).value;
}
return oValsGPM;
}
Here is the other...
function AddPressure() {
// Set up an array of field names
var aNames = ["Red10", "Red20", "Red30", "Red40",
"Brown10", "Brown20", "Brown30", "Brown40",
"Grey10", "Grey20", "Grey30", "Grey40",
"White10", "White20", "White30", "White40",
"Blue10", "Blue20", "Blue30", "Blue40"];
// Set up an object that will be returned
var oValsPressure = {};
// Loop through the field names and add name/value pairs to the object
for (var i = 0; i < aNames.length; i += 1) {
oValsPressure[aNames] = getField(aNames).value;
}
return oValsPressure;
}
I am trying to change the background color of the field depending upon the value being greater or = to a value AND less than another value AND
being dependent upon a different field being greater or = to yet another field.
var oVP=AddPressure();
var oVG=AddGPM();
var P28=this.getField ("P28").value;
var L30=this.getField("L30").value;
if(P28>=(oVG["N36"])
AND
(oVG["N37]))
AND
(oVP["Red10"]>=("L30")){
event.target.fillColor=color.yellow;
return;
}
I keep getting syntaxerror messages.
Where am I messing up?
OK, I see what happened. Just remove the quotes around "L30" and it should work.
Copy link to clipboard
Copied
Replace AND with && ...
However, this kind of condition doesn't make sense: oVP["Red10"]>=("L30")
You're comparing a number to a string, it seems. That won't work.
On Tue, Nov 8, 2016 at 5:42 PM, davidm76220796 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Can I CAST L30 as a number ?
Copy link to clipboard
Copied
No, because it's not a number. What would be the result of doing that, anyway?
Copy link to clipboard
Copied
The form I created has field L30 set as a number field. Is the way I am pulling it into this condition messing up the number?
(I am sorry I am so ignorant, I am not understanding why the number is not coming over. Thanks for your patience.)
Copy link to clipboard
Copied
OK, I see what happened. Just remove the quotes around "L30" and it should work.
Copy link to clipboard
Copied
I am getting a SyntaxError: syntax error 8: at line 9
I tried removing the quotes from both of the ("L30") and then I tried like this.
var oVP=AddPressure();
var oVG=AddGPM();
var P28=this.getField ("P28").value;
var L30=this.getField("L30").value;
if(P28>=(oVG["N36"])
&&
(oVG["N37"]))
&&
(oVP["Red10"]>=(L30)){
event.target.fillColor=color.yellow;
return;
}
Copy link to clipboard
Copied
Count the number of your opening and closing parentheses...
On Tue, Nov 8, 2016 at 7:48 PM, davidm76220796 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
OMG
I can't believe I missed that! I swear I counted them multiple times.
Thank You 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now