Answered
I'm using the following code that originated from an example file on this sight, "Programming Lists Part 1":
function SetRacialBonus() { var oASRTB = { Dragonborn: [2,0,0,0,0,2], Dwarf: [0,2,0,0,2,0], Eladrin: [0,0,2,2,0,0], Elf: [0,0,2,0,2,0], Half_Elf: [0,2,0,0,0,2], Halfling: [0,0,2,0,0,2], Tiefling: [0,0,0,2,0,2], }; if(!event.willCommit) { var nSelExp = 0; if(!isNaN(event.changeEx)) nSelExp = event.changeEx this.getField("Ability_STR_Race").value = nSelExpo; this.getField("Ability_CON_Race").value = nSelExpo[ASRTB][0]; this.getField("Ability_DEX_Race").value = nSelExpo[ASRTB][1]; this.getField("Ability_INT_Race").value = nSelExpo[ASRTB][2]; this.getField("Ability_WIS_Race").value = nSelExpo[ASRTB][3]; this.getField("Ability_WIS_Race").value = nSelExpo[ASRTB][4]; } }
While I'm not getting any errors, I'm also not seeing the values applied to the appropriate fields.
The script is document level and the function is set in the format tab as custom keystroke script. I copied the method in which the example demonstrated this use. Could someone please tell me where I went wrong in this?
Thanks in advance for any help that may be provided.
this.getField("Ability_CON_Race").value = nSelExpo[ASRTB][0];
The variable nSelExp must be a number or string primitive: either the number zero or the export value of the selected combo box item, which is a string, even though isNaN may (but probably doesn't) think it's a number, since you're assigning it the value of event.changeEx, which is a string. You're then attempting to access a property (or index) of this variable (again, which is a number or string primitive) given by whatever value ASTRB is, which is not clear given the code you posted. This will almost certainly fail since nSelExp is either a number (zero) or a string, not an Object or Array. The variable oASRTB is the Object you defined, but this is not the same as the variable ASRTB you're attempting to use.
Since I don't know what you set the export values of the combo box items to, I'll have to guess that what you really want to do is something like:
But it's a bit hard to say without more information.
George