I want to indicate to the user that a particular row of a repeating section contains the currently equipped weapon (eg. change the background colour, or give it a coloured border) and I can't think of a way that isn't overly complicated to ensure that only one row is highlighted at a time. Here's the repeating section: <fieldset class="repeating_meleeweapons">
Weapon name <input type="text" name="attr_meleeweaponname" class="eightmidtextinput" />
<br>
Weapon type <input type="text" name="attr_meleeweapon" list="meleeweapon" class="eightmidtextinput" />
<datalist id="meleeweapon">
<option value="Battleaxe" data-abr="d8" data-damage="6">
<!-- more options here -->
</datalist>
<br>
Magic Bonus <input type="number" name="attr_magicmeleeweaponbonus" min="0" max="3" value="0" class="fourshorttextinput" />
Armour Bypass Roll <input type="text" name="attr_meleeabr" value="0" class="fourshorttextinput" />
Damage <input type="text" name="attr_meleedamage" value="0" size="4" class="fourshorttextinput" />
Other Effects <textarea name="attr_meleeothereffects">
</textarea>
<br>
<button type="action" name="act_equippedmeleewep">Equip</button>
</fieldset>
The action button: on("clicked:repeating_meleeweapons:equippedmeleewep", function(eventInfo) {
// Get the row ID of the clicked button
const rowId = eventInfo.triggerName.split('_')[2];
// Define the fields to retrieve from the current row
const fields = [
`repeating_meleeweapons_${rowId}_meleeweaponname`,
`repeating_meleeweapons_${rowId}_meleeweapon`,
`repeating_meleeweapons_${rowId}_magicmeleeweaponbonus`,
`repeating_meleeweapons_${rowId}_meleeabr`,
`repeating_meleeweapons_${rowId}_meleedamage`,
`repeating_meleeweapons_${rowId}_meleeothereffects`
];
// Get the attributes of the current row
getAttrs(fields, function(values) {
const output = {
equippedmeleeweaponname: values[`repeating_meleeweapons_${rowId}_meleeweaponname`] || "",
equippedmeleeweapontype: values[`repeating_meleeweapons_${rowId}_meleeweapon`] || "",
equippedmeleeweaponmagicbonus: values[`repeating_meleeweapons_${rowId}_magicmeleeweaponbonus`] || 0,
equippedmeleeweaponabr: values[`repeating_meleeweapons_${rowId}_meleeabr`] || "0d0",
equippedmeleeweapondamage: values[`repeating_meleeweapons_${rowId}_meleedamage`] || "0",
equippedmeleeweaponother: values[`repeating_meleeweapons_${rowId}_meleeothereffects`] || ""
};
// Set the output attributes
setAttrs(output);
});
});