Skip to main content
stevenm8611492
Known Participant
October 10, 2016
Question

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

  • October 10, 2016
  • 1 reply
  • 973 views

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);}}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
October 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.

stevenm8611492
Known Participant
October 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

try67
Community Expert
Community Expert
October 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?