I am obviously doing something wrong. I want to click a button on my character sheet (or click a checkbox on to create an event) Here is the follow codes I am using for the text worker, as well as part of my html (I looked through for typos but I couldn't find them, doesn't mean they are there) Also note I made said macro as a mashup of several posts on the forums when I attempted to look up how to perform the task I am trying. Now to the code! on(`change:short_rest clicked:actionshortrest`, function (eventinfo) {
//Section of repeating to be checking
let section = "classresources";
//get proper id for repeating sections (repeating_classresources_)
getSectionIDs(`repeating_${section}`, function (idArray) {
let fields = ["ClassResourceName", "ClassResourceRecharge", "ClassResourceTotal", "ClassResourceTotal_max"];
const attrArray = idArray.reduce( (m,id) => [...m, ...(fields.map(field => `repeating_${section}_${id}_${field}`))],[]);
getAttrs(attrArray, function (values) {
const setattrobj = {};
values.forEach(item =>{
//check if ClassResourceRecharge has been set to the string "Short Rest" (this attr is set with a dropdown)
if(values.ClassResourceRecharge == "Short Rest" ){
setattrobj.ClassResourceTotal = parseInt(values["ClassResourceTotal_max"])||0;
}
});
//check if empty or not
if(setattrobj) {
setAttrs(setattrobj);
}
// set checkbox back to 0 to uncheck it, regardless of results
// when I put the below setAttrs here in the code, it doesn't execute
});
});
// setAttrs is executeing fine, reset the checkbox
setAttrs({"short_rest":0});
}); And.... part with action button and checkbox (I tried using hidden attribute with the checkbox and that didn't seem to work either) Got the Short rest below to work but had to move the setAttrs to outside the getAttrs functions <div class="sheet-row">
<div class="sheet-col-4-5 sheet-center sheet-small-label sheet-sub-header sheet-padl sheet-padr">Short & Long Rests</div>
<div class="sheet-row">
<div class="sheet-col-2-5 sheet-padl sheet-align-left sheet-padr">
<input type="hidden" name ="attr_hidden_short_rest" value="1"/>
<input type="checkbox" name="attr_short_rest" value="1"/>
<button type="button" name="act_actionshortrest" title="Click me to take a Short Rest!"><span style="font-family: fontello">&#xe808;</span>:Take Short Rest?</button>
</div>
<div class="sheet-col-2-5 sheet padl sheet-align-right sheet-padr">
<input type="hidden" name ="attr_hidden_long_rest" value="1"/>
<input type="checkbox" name="attr_long_rest" value="@{hidden_longrest}"/>
<button type="button" name="act_actionlongrest" title="Click me to take a Long Rest!"><span style="font-family: fontello">&#xe803;:</span>Take Long Rest?</button>
</div>
</div>
</div> And repeating section part of my html <fieldset class="repeating_classresources">
<div class="sheet-row">
<div class="sheet-col-5-12">
<input type="text" name="attr_ClassResourceName" />
</div>
<div class="sheet-col-1-4">
<select name="attr_ClassResourceRecharge">
<option value="None">None</option>
<option value="Short Rest">Short Rest</option>
<option value="Long Rest">Long Rest</option>
<option value="Other">Other</option>
</select>
</div>
<div class="sheet-col-1-6">
<input type="number" name="attr_ClassResourceTotal" value="1" min="0" step="1" />
</div>
<div class="sheet-col-1-6">
<input type="number" name="attr_ClassResourceTotal_max" value="1" min="0" step="1" />
</div>
</div>
</fieldset> My Class resource page with resources does not reset, see below. While writing this post, I was able to atleast get my sheetworker to recognize and change my checkbox back to unchecked, however Still doesn't reset my classresources... and I am not sure what it is that I am doing wrong... I seen some code with getSectionId inside getAttrs and I seen other with getAttrs inside the getSectionId code.... not sure if it matters or which one is "best practice" If anyone looking at this see's why it wouldn't be making changes I would be sooooo happy :) Thank you for your time. Few more pictures of the sheet.. And this...