Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[HELP] Can a radio button group be used with a repeating field

1526792799
Darren
Pro
Sheet Author
API Scripter
Game system has about a dozen preset combat maneuvers.  Players can purchase additional combat maneuvers.  I would like a radio button for the player to select which combat maneuver their character will use.  Here is a stripped down code sample: <div class="line"> <div class="am0"><input type="radio" name="radio_maneuver" /></div> <div class="am1">Shove</div> <div class="am2">-1</div> <div class="am2">-1</div> <div class="am4">Push 1m per 5 STR</div> </div> <div class="line"> <div class="am0"><input type="radio" name="radio_maneuver" /></div> <div class="am1">Strike</div> <div class="am2">+0</div> <div class="am2">+0</div> <div class="am4">STR or Weapon</div> </div> <div class="line"> <div class="am0"><input type="radio" name="radio_maneuver" /></div> <div class="am1">Throw</div> <div class="am2">+0</div> <div class="am2">+0</div> <div class="am4">Throw w/ STR dmg</div> </div> <div class="line"> <div class="am0"><input type="radio" name="radio_maneuver" /></div> <div class="am1">Trip</div> <div class="am2">-1</div> <div class="am2">-2</div> <div class="am4">Knock target prone</div> </div> <fieldset class="repeating_maneuvers"> <div class="line"> <div class="am0"><input type="radio" name="radio_maneuver" /></div> <input type="text" class="am1 edit-show" name="attr_maneuver_name" value="" /> <input type="text" class="am2 edit-show" name="attr_maneuver_ocv" value="" /> <input type="text" class="am2 edit-show" name="attr_maneuver_dcv" value="" /> <input type="text" class="am4 edit-show" name="attr_maneuver_effect" value="" /> </div> </fieldset> The above does not work because the repeating field rowid is added to the attribute name.  Is there a way to do this?  Currently, I can only think of using checkboxes and adding javascript that will clear all other checkboxes anytime one is checked.
1526808362
GiGs
Pro
Sheet Author
API Scripter
Darren said: The above does not work because the repeating field rowid is added to the attribute name.  Is there a way to do this?  Currently, I can only think of using checkboxes and adding javascript that will clear all other checkboxes anytime one is checked. This is the only way I know to do it, too. As you've found, the radio button on each row will always have a different name, so you can't use them. What you can do use checkboxes, and style them so they look like radio buttons. 
1526894074
Finderski
Pro
Sheet Author
Compendium Curator
First of all, the name should not be "radio_manuever", but "attr_manuever".  As for your question...the way you're using it above, no.  Because the name of the radio button field in the repeating fieldset is not "maneuver", but "repeating_maneuvers_somelongID_manuever" and the "somelongID" will be different for each radio button. You can use radio buttons within the same repeating row, but not to go across rows. Given that, your assessment of using a sheet work seems to be the best solution.
1526901209

Edited 1526901415
DXWarlock
Sheet Author
API Scripter
Is the radio buttons part of this what your trying to do(of sorts)? I use this: <fieldset class="repeating_EquipList"> <input class="sheet-ONBODY" type="hidden" name="attr_EquipPlace" value=""> <input class="sheet-EQCHECK" type='checkbox' name='attr_Equipped' value="1"> <div class="sheet-INLINE"> <input class="sheet-eq" value="1" type="number" style="width:20px;" name="attr_EquipNum"> <input class="sheet-EQUIP2" type="text" style="width:175px;" name="attr_EquipL" value="Item"> Lbs:<input value="1" type="number" step="any" style="width:25px;" name="attr_EquipWei">|-| <input class="sheet-fa" type='radio' value='1y' name='attr_EquipPlace' /><label for="ossm">BackPack</label> <input class="sheet-fa" type='radio' value='2y' name='attr_EquipPlace' /><label for="ossm">Pocket</label> <input class="sheet-fa" type='radio' value='3y' name='attr_EquipPlace' /><label for="ossm">Hip</label> <input class="sheet-fa" type='radio' value='4y' name='attr_EquipPlace' /><label for="ossm">Back</label> <input class="sheet-fa" type='radio' value='5y' name='attr_EquipPlace' /><label for="ossm">Satchel</label> <input class="sheet-fa" type='radio' value='6y' name='attr_EquipPlace' /><label for="ossm">Body</label> <input class="sheet-fa" type='radio' value='7y' name='attr_EquipPlace' /><label for="ossm">Belt</label>|| <input class="sheet-aa" type='radio' value='8n' name='attr_EquipPlace' /><label for="ossm">Vehicle</label> <input class="sheet-aa" type='radio' value='9n' name='attr_EquipPlace' /><label for="ossm">Pers.Veh</label> <input class="sheet-aa" type='radio' value='10n' name='attr_EquipPlace' checked='true' /><label for="ossm">House</label> </div> <hr class="repeating"> </fieldset> To do my radio options in repeating. it gives me this (selecting any one deselects the others):
1526902910
GiGs
Pro
Sheet Author
API Scripter
It looks like your radio buttons are used within  a single row. What Darren wants is a radio button that works across multiple rolls. Like, say in your pic, if you clicked Belt in any of those rows, all the Belts in other rows would be deselected.
1526911145
Darren
Pro
Sheet Author
API Scripter
G G is correct.  Here is a pic of what it looks like right now.  I was asking if the radio button group could include elements both inside and outside the repeating group.  And from the replies, it sounds like the answer is no.
1526913363
Finderski
Pro
Sheet Author
Compendium Curator
If you want to go the Sheetwork route, something you could do would be use checkboxes (as you'd mentioned) but create a new hidden field that is populated with the "last used" checkbox. That way when you listen for a change in checkboxes all you need to do is refer to that other field and uncheck that box.  So, for example, given the image above, if I clicked on Flying Dodge, that triggers the sheet worker, then you check to see if last_used === what triggered the sheet worker and if it is different, you clear the field in last_used and update last_used with Flying Dodge.  You may also want to check to make sure something is checked, because if I went in and clicked Flying Dodge a second time, it is now unchecked (and nothing is checked).