Copy link to clipboard
Copied
So,
what I'm trying to do...
get a sum of several fields, but only if they are returning values, and if not, do not sum
The field I want to sum is populated by a dropdown menu...
The fields I want to add to it are populated by different dropdown menus...
End result is
I need the field populated by the first dropdown to add or subtract a number depending on if other fields are returning values
Here's all the script I have that run the document
I need
RS +- ARS, ARSA, ARSB
And
Size +- AAS, AASA, AASB
Can anyone help??
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<Document-Level>
//<ACRO_source>carddata</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:carddata ***********/
// Place all prepopulation data into a single data structure
var Carddata = { Jarl:{ AP: "3",
SP: "5",
MA: "3",
RA: "2",
DF: "3",
RS: "1",
DR: "3",
MN: "2",
HP: "3",
Size: "2",
UnitRank: "War Clan Leader",
Base: "30mm",
Glorycost: "160",
Specialabilities: "Combat Sense, Tactician (12), Teamwork, Hip Shot, Weapon Master"},
Bondi:{ AP: "2",
SP: "5",
MA: "2",
RA: "1",
DF: "2",
RS: "1",
DR: "2",
MN: "2",
HP: "2",
Size: "2",
UnitRank: "War Clan Warrior",
Base: "30mm",
Glorycost: "40",
Specialabilities: " "},
Huskarl:{ AP: "2",
SP: "5",
MA: "3",
RA: "0",
DF: "3",
RS: "2",
DR: "3",
MN: "2",
HP: "2",
Size: "2",
UnitRank: "War Clan Protector",
Base: "30mm",
Glorycost: "60",
Specialabilities: "Brace, High Pain Treshold, Stalwart"},
Berserker:{ AP: "2",
SP: "6",
MA: "3",
RA: "0",
DF: "1",
RS: "2",
DR: "4",
MN: "1",
HP: "2",
Size: "2",
UnitRank: "War Clan Shock Trooper",
Base: "30mm",
Glorycost: "80",
Specialabilities: "Berserker, Rapid Attack, Terrifying (1)"},
Skald:{ AP: "2",
SP: "5",
MA: "2",
RA: "1",
DF: "2",
RS: "1",
DR: "2",
MN: "3",
HP: "2",
Size: "2",
UnitRank: "War Clan Coordinator",
Base: "30mm",
Glorycost: "70",
Specialabilities: "Tactician (6), Taunt (2)"},
Gothi:{ AP: "2",
SP: "5",
MA: "2",
RA: "0",
DF: "2",
RS: "1",
DR: "3",
MN: "3",
HP: "2",
Size: "2",
UnitRank: "War Clan Priest",
Base: "30mm",
Glorycost: "60",
Specialabilities: "Healer (ML), Godspark Attuned"},
Speider:{ AP: "2",
SP: "6",
MA: "1",
RA: "2",
DF: "3",
RS: "1",
DR: "2",
MN: "2",
HP: "2",
Size: "2",
UnitRank: "War Clan Scout",
Base: "30mm",
Glorycost: "70",
Specialabilities: "Concealment, Stealth"}};
function SetFieldValues(cUnitType)
{
this.getField("AP").value = Carddata[cUnitType].AP;
this.getField("SP").value = Carddata[cUnitType].SP;
this.getField("MA").value = Carddata[cUnitType].MA;
this.getField("RA").value = Carddata[cUnitType].RA;
this.getField("DF").value = Carddata[cUnitType].DF;
this.getField("RS").value = Carddata[cUnitType].RS;
this.getField("DR").value = Carddata[cUnitType].DR;
this.getField("MN").value = Carddata[cUnitType].MN;
this.getField("HP").value = Carddata[cUnitType].HP;
this.getField("Size").value = Carddata[cUnitType].Size;
this.getField("UnitRank").value = Carddata[cUnitType].UnitRank;
this.getField("Base").value = Carddata[cUnitType].Base;
this.getField("Glorycost").value = Carddata[cUnitType].Glorycost;
this.getField("Specialabilities").value = Carddata[cUnitType].Specialabilities;
}
// Place all prepopulation data into a single data structure
var weapondata = { Atgeir:{ ST: "3",
RN: "MR",
Special: "No shield while in use",
glorycost: "20"},
Axe:{ ST: "2",
RN: "ML",
Special: " ",
glorycost: "10"},
Sword:{ ST: "2",
RN: "ML",
Special: " ",
glorycost: "10"},
Hammer:{ ST: "2",
RN: "ML",
Special: " ",
glorycost: "10"},
Club:{ ST: "1",
RN: "ML",
Special: " ",
glorycost: "5"},
Dagger:{ ST: "1",
RN: "ML",
Special: " ",
glorycost: "5"},
Great_Weapon:{ ST: "3",
RN: "ML",
Special: "No shield while in use",
glorycost: "15"},
Scythe:{ ST: "2",
RN: "ML",
Special: "Savage, Cumbersome, No shield while in use",
glorycost: "25"},
Spear:{ ST: "2",
RN: "MR",
Special: " ",
glorycost: "15"},
Ulfbert:{ ST: "3",
RN: "ML",
Special: "Lethal",
glorycost: "65"},
Yew_Bow:{ ST: "2",
RN: "18",
Special: "No shield while in use",
glorycost: "30"},
Sling:{ ST: "0",
RN: "12",
Special: " ",
glorycost: "15"},
Throwing_Spear:{ ST: "2",
RN: "12",
Special: " ",
glorycost: "25"},
Throwing_Axe:{ ST: "2",
RN: "6",
Special: " ",
glorycost: "20"},
Throwing_Hammer:{ ST: "2",
RN: "6",
Special: " ",
glorycost: "20"},
Throwing_Dagger:{ ST: "1",
RN: "6",
Special: " ",
glorycost: "15"}};
function SetweaponsValues(cWeapons)
{
this.getField("ST").value = weapondata[cWeapons].ST;
this.getField("RN").value = weapondata[cWeapons].RN;
this.getField("Special").value = weapondata[cWeapons].Special;
this.getField("glorycost").value = weapondata[cWeapons].glorycost;
}
function Setweapons1Values(cWeapons1)
{
this.getField("STA").value = weapondata[cWeapons1].ST;
this.getField("RNA").value = weapondata[cWeapons1].RN;
this.getField("SpecialA").value = weapondata[cWeapons1].Special;
this.getField("glorycostA").value = weapondata[cWeapons1].glorycost;
}
function Setweapons2Values(cWeapons2)
{
this.getField("STB").value = weapondata[cWeapons2].ST;
this.getField("RNB").value = weapondata[cWeapons2].RN;
this.getField("SpecialB").value = weapondata[cWeapons2].Special;
this.getField("glorycostB").value = weapondata[cWeapons2].glorycost;
}
// Place all prepopulation data into a single data structure
var armordata = { Light_Leathers:{ ARS: "1",
AAS: "0",
armorcost: "5"},
Scale:{ ARS: "2",
AAS: "0",
armorcost: "10"},
Chain:{ ARS: "2",
AAS: "0",
armorcost: "10"},
Heavy:{ ARS: "3",
AAS: "0",
armorcost: "15"},
Shield:{ ARS: "0",
AAS: "2",
armorcost: "5"}};
function SetArmorValues(cArmor)
{
this.getField("ARS").value = armordata[cArmor].ARS;
this.getField("AAS").value = armordata[cArmor].AAS;
this.getField("armorcost").value = armordata[cArmor].armorcost;
}
function SetArmor1Values(cArmor1)
{
this.getField("ARSA").value = armordata[cArmor1].ARS;
this.getField("AASA").value = armordata[cArmor1].AAS;
this.getField("armorcostA").value = armordata[cArmor1].armorcost;
}
function SetArmor2Values(cArmor2)
{
this.getField("ARSB").value = armordata[cArmor2].ARS;
this.getField("AASB").value = armordata[cArmor2].AAS;
this.getField("armorcostB").value = armordata[cArmor2].armorcost;
}
//</ACRO_script>
//</Document-Level>
//<AcroForm>
//<ACRO_source>Armor:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Armor:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["ARS","AAS","armorcost"]);
else
SetArmorValues(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Armor1:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Armor1:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["ARSA","AASA","armorcostA"]);
else
SetArmor1Values(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Armor2:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Armor2:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["ARSB","AASB","armorcostB"]);
else
SetArmor2Values(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>UnitType:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:UnitType:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["AP","SP","MA","RA","DF","RS","DR","MN","HP","Size","UnitRank","Base","Glorycost","Specialabilities"]);
else
SetFieldValues(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Weapons:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Weapons:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["ST","RN","Special","glorycost"]);
else
SetweaponsValues(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Weapons1:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Weapons1:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["STA","RNA","SpecialA","glorycostA"]);
else
Setweapons1Values(event.value);
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>Weapons2:Keystroke</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Weapons2:Keystroke ***********/
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["STB","RNB","SpecialB","glorycostB"]);
else
Setweapons2Values(event.value);
}
//</ACRO_script>
//</AcroForm>
Have something to add?