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

Dropdown list of 128 items, 7 items affects different fields, having problems with which code to use

New Here ,
Oct 10, 2016 Oct 10, 2016

Dropdown list of 128 items, 7 items affects different fields, having problems with which code to use

this does not work but it has no errors

The functions work separately with the each owns "event.will commit"

var CurrentValueCSk1 = this.getField("CSk1");

for (var i=0; i < CurrentValueCSk1.numItems; i++)
var CurrentValueCSk1Now = (CurrentValueCSk1.getItemAt(i,true) + ":  " + CurrentValueCSk1.getItemAt(i,false));

if (CurrentValueCSk1Now == "Marksmanship") { if(event.willCommit){if(event.value == "") this.resetForm (["BSMarksmanship_Hid"]);
else SetBSMarksmanshipFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Very Strong") { if(event.willCommit){if(event.value == "") this.resetForm (["StrongVery_Hid"]);
else SetStrongVeryFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Strongman") { if(event.willCommit){if(event.value == "") this.resetForm (["Strongman_Hid"]);
else SetStrongmanModifierFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Very Resilient") { if(event.willCommit){if(event.value == "") this.resetForm (["VeryResilient_Hid"]);
else SetVeryResilientFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Lightning Relexes") { if(event.willCommit){if(event.value == "") this.resetForm (["ILightning_Reflexes_Hid"]);
else SetLightningReflexesFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Fleet Footed") { if(event.willCommit){if(event.value == "") this.resetForm (["MSFleet_Footed_Hid"]);
else SetFleetFootedFieldValues(event.value);}}

else if (CurrentValueCSk1Now == " ") { if(event.willCommit){if(event.value == "") this.resetForm (["VeryResilient_Hid", "Strongman_Hid", "StrongVery_Hid", "MSFleet_Footed_Hid", "ILightning_Reflexes_Hid", "BSMarksmanship_Hid"]);
else SetResetSkillModifiersFieldValues(event.value);}}

TOPICS
Acrobat SDK and JavaScript , Windows
888
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 ,
Oct 10, 2016 Oct 10, 2016

You should really study some core JS syntax...

Code that goes together needs to be placed in a block, surrounded by curly brackets.

So your code needs to be:

for (var i=0; i < CurrentValueCSk1.numItems; i++) {

// rest of code

}

Otherwise only the first line after the for-loop will be associated with it.

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
New Here ,
Oct 11, 2016 Oct 11, 2016

Thanks for pointing that out, it has been some time from my Java class, added the { }, but no luck. I don't know if I'm going in the right direction with this code

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 ,
Oct 11, 2016 Oct 11, 2016

It's JavaScript, not Java. Similar names, but completely different languages.

Regarding your code: I don't see how it can work. You set the value of the CurrentValueCSk1Now variable to "export value: display value", but then you're comparing it to what seems to be the display value only ("Marksmanship", "Very Strong", etc.), so how can it ever be true?

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
New Here ,
Oct 12, 2016 Oct 12, 2016

The List Field does not have an Export value for the data

So this should return the item name, correct?

CurrentValueCSk1.getItemAt(i,false)

http://help.adobe.com/livedocs/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/common/html/wwhelp...

bExportValue (optional, Acrobat 5.0) Specifies whether to return an export value:
If true (the default), if the item has an export value, it is returned. If there is no export value, the item name is returned.
If false, the method returns the item name.

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 ,
Oct 13, 2016 Oct 13, 2016

If that's the case then why include the export value in the script in the first place? Just use the display value.

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
New Here ,
Oct 20, 2016 Oct 20, 2016

so what you are saying is use this

var CurrentValueCSk1 = this.getField("CSk1");

if (CurrentValueCSk1Now == "Marksmanship") { if(event.willCommit){if(event.value == "") this.resetForm (["BSMarksmanship_Hid"]);
else SetBSMarksmanshipFieldValues(event.value);}}

else if (CurrentValueCSk1Now == "Very Strong") { if(event.willCommit){if(event.value == "") this.resetForm (["StrongVery_Hid"]);
else SetStrongVeryFieldValues(event.value);}}

.......

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 ,
Oct 21, 2016 Oct 21, 2016

It's a bit difficult to follow without formatting and indentation, but I guess so, yes...

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
New Here ,
Oct 24, 2016 Oct 24, 2016
LATEST

So this is not working; therefore try try again, added .valueAsString, not working

var CurrentValueCSk1 = this.getField("CSk1").valueAsString;

if (CurrentValueCSk1.valueAsString == "Marksmanship") { if(event.willCommit){if(event.value == "") this.resetForm (["BSMarksmanship_Hid"]);

else SetBSMarksmanshipFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Very Strong") { if(event.willCommit){if(event.value == "") this.resetForm (["StrongVery_Hid"]);

else SetStrongVeryFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Strongman") { if(event.willCommit){if(event.value == "") this.resetForm (["Strongman_Hid"]);

else SetStrongmanModifierFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Very Resilient") { if(event.willCommit){if(event.value == "") this.resetForm (["VeryResilient_Hid"]);

else SetVeryResilientFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Lightning Relexes") { if(event.willCommit){if(event.value == "") this.resetForm (["ILightning_Reflexes_Hid"]);

else SetLightningReflexesFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Fleet Footed") { if(event.willCommit){if(event.value == "") this.resetForm (["MSFleet_Footed_Hid"]);

else SetFleetFootedFieldValues(event.value);}

}

else if (CurrentValueCSk1.valueAsString == "Strike Mighty Blow") { if(event.willCommit){if(event.value == "") this.resetForm (["StrikeMightyBlow_Hid"]);

else SetStrikeMightyBlowFieldValues(event.value);}

}

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