Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional AND making Background Color change

Community Beginner ,
Nov 08, 2016 Nov 08, 2016

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?

TOPICS
Acrobat SDK and JavaScript , Windows
969
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 08, 2016 Nov 08, 2016

OK, I see what happened. Just remove the quotes around "L30" and it should work.

Translate
Community Expert ,
Nov 08, 2016 Nov 08, 2016

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

Can I CAST L30 as a number ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

No, because it's not a number. What would be the result of doing that, anyway?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

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.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

OK, I see what happened. Just remove the quotes around "L30" and it should work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 08, 2016 Nov 08, 2016

Count the number of your opening and closing parentheses...

On Tue, Nov 8, 2016 at 7:48 PM, davidm76220796 <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2016 Nov 08, 2016
LATEST

OMG

I can't believe I missed that!  I swear I counted them multiple times.

Thank You 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines