So, to do this there's a few things that need to be setup in the code: an input to store the button call since we can't edit roll button values A sheetworker that will trigger on changes to character name, changes to the repeating section, and sheet opened. This looks like: <div>
<fieldset class="repeating_stuff">
<input name="attr_item" placeholder="Enter an item" type="text">
<input name="attr_color" placeholder="Enter its color" type="text">
<br>
<button name="roll_showitem" value="&{template:default}{{item=@{item}}}" type="roll">Show the Item</button>
<br>
<button name="roll_showcolor" value="&{template:default}{{color=@{color}}}" type="roll">Show the Color</button>
<br>
<input type="hidden" name="attr_color_button" value="">
<button name="roll_testbutton" value="&{template:default}{{item=@{item}}} {{@{color_button}}}" type="roll">Test Button</button>
<br>
<div style="width:450px;">
<p>Press the Test Button, then click its in-chat button to show the color.
It needs to know the row, which needs to be done via sheetowrker,
but I have absolutely no idea how to do that on either the HTML side or the
script side. There will of course be multiple repeating rows, so it needs to do
it for each row. Not sure which 'on' events should trigger the function.</p>
<p>If you can get this working and show me the HTML and the script,
I think I can figure out how to apply it to all my needs on my custom sheet.
Thanks a million. Twenty million!, why not? Plus, think of all the gratitude
of the citizens of the United Planetary Federation! That's gotta be worth something!</p>
</div>
<hr>
</fieldset>
</div>
<script type="text/worker">
const setButtonCalls = function(event){
getSectionIDs('repeating_stuff',(idArray)=>{
getAttrs(['character_name'],(attributes)=>{
const setObj = idArray.reduce((memo,id)=>{
memo[`repeating_stuff_${id}_color_button`] = `[Show the Color](~${attributes.character_name}|repeating_stuff_${id}_showcolor)`;
return memo;
},{});
setAttrs(setObj,{silent:true});
});
});
};
on('sheet:opened change:character_name change:repeating_stuff',setButtonCalls);
</script> The only changes that were made to the html were to change {{[Show the Color](~showcolor)}} to {{@{color_button}}} , and add a hidden attribute called color_button . The script takes care of the rest. EDIT: Note that this could also be handled via CRP, but that will require bigger changes to your existing HTML and need a more in depth script. EDIT 2: This is a shotgun solution, but can be made more specific by separating out the repeating section change listener to only affect the repeating row. The script would look like this: const parseTriggerName = function(string){
let match = string.match(/(?:(repeating_[^_]+)_([^_]+)_)?(.+)/);
match.shift();
return match;
};
const setButtonCall = function(event){
const [,id] = parseTriggerName(event.sourceAttribute);
getAttrs(['character_name'],(attributes)=>{
setObj = {};
setObj[`repeating_stuff_${id}_color_button`] = createButton(attributes.character_name,id);
setAttrs(setObj,{silent:true});
});
};
const setButtonCalls = function(event){
getSectionIDs('repeating_stuff',(idArray)=>{
getAttrs(['character_name'],(attributes)=>{
const setObj = idArray.reduce((memo,id)=>{
memo[`repeating_stuff_${id}_color_button`] = createButton(attributes.character_name,id);
return memo;
},{});
setAttrs(setObj,{silent:true});
});
});
};
const createButton = function(characterName,id){
return `[Show the Color](~${characterName}|repeating_stuff_${id}_showcolor)`;
};
on('sheet:opened change:character_name',setButtonCalls);
on('change:repeating_stuff',setButtonCall);