Copy link to clipboard
Copied
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);}}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
The List Field does not have an Export value for the data
So this should return the item name, correct?
CurrentValueCSk1.getItemAt(i,false)
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.
Copy link to clipboard
Copied
If that's the case then why include the export value in the script in the first place? Just use the display value.
Copy link to clipboard
Copied
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);}}
.......
Copy link to clipboard
Copied
It's a bit difficult to follow without formatting and indentation, but I guess so, yes...
Copy link to clipboard
Copied
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);}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now