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

Drop down menu with a button that rolls a dice

Hi, I am creating a basic character sheet for my Forged in the Dark game. I am not a coder but I have managed to make a simple sheet that does most of what I want. One thing I would like is to add is a drop-down menu for different weapon options and a button to roll a dice. i have made the drop-down menu easily enough, but I can't figure out how to make the button roll a dice. Each option in the menu has a different value - basically when you use a simple weapon like a pistol you roll a D6, and for a more powerful you might roll a d12. Anyone knows the code I could use to make a dropdown menu and button combination that does this?   <option value="zero">-</option>   <option value="d6">Pistol</option>   <option value="d8">Submachine Gun</option>   <option value="d12">Sniper Rifle</option>     </select> <button id="rollButton">Roll Dice</button>
1703090425

Edited 1703090624
vÍnce
Pro
Sheet Author
Hi Gary, here's how you can handle button rolls on your sheet; <a href="https://wiki.roll20.net/Button#Roll_Macro" rel="nofollow">https://wiki.roll20.net/Button#Roll_Macro</a> Just use a basic roll button ie type="roll", and set it's value to match your select attribute.
Thank you for your reply. How do I make it roll a different dice depending on which option from the dropdown is selected?
1703096226

Edited 1703096864
vÍnce
Pro
Sheet Author
Whatever value you have in your dropdown should be what is sent to chat.&nbsp;Given that the values in your select is "d6, d8, etc." That text is all that you will see since rolls require "/r" or an inline roll ie [[d6]], etc. So if you want to actually make a roll with only the select's value, you will need to modify the value of your options accordingly. But if your dropdown is only one component of your macro/roll, you'll need to piece everything together so that all your roll button is doing is sending your "final" macro to chat.&nbsp; Example; you might have multiple attributes that you want in your final roll. Let's say that weapon1_die is your drop-down select, and misc_mod is some other attribute and your Final roll is, &amp;{template:default} {{name=Attack}} {{roll=[[ @{weapon1_die} + @{misc_mod} ]]}} You can place that final roll in a new attribute &lt;input type="text" name="attr_weapon1_attack" value="&amp;{template:default} {{name=Attack}} {{roll=[[ @{weapon1_die} + @{misc_mod} ]]}}" /&gt; Then just use weapon1_attack as the value for your button roll. &lt;button type="roll" name="roll_weapon1_attack_roll" value="weapon1_attack"&gt;Attack!&lt;/button&gt;
Thanks for spending the time to answer. I still don't get it. At the moment nothing is being sent to chat. The button doesn't seem to do anything. I currently don't want to add any modifiers - just roll a single dice - but a different dice depending on the choice shown in the dropdown. This is my current code...&nbsp; &lt;select name="attr_rollmod"&gt; &nbsp; &lt;option value="zero"&gt;-&lt;/option&gt; &nbsp; &lt;option value="d6"&gt;Pistol&lt;/option&gt; &nbsp; &lt;option value="d8"&gt;Submachine Gun&lt;/option&gt; &nbsp; &lt;option value="d12"&gt;Sniper Rifle&lt;/option&gt; &nbsp; &nbsp; &lt;/select&gt; &lt;button id="rollButton"&gt;Roll Dice&lt;/button&gt;
1703100276

Edited 1703100816
vÍnce
Pro
Sheet Author
Gary A. said: Thanks for spending the time to answer. I still don't get it. At the moment nothing is being sent to chat. The button doesn't seem to do anything. I currently don't want to add any modifiers - just roll a single dice - but a different dice depending on the choice shown in the dropdown. This is my current code...&nbsp; &lt;select name="attr_rollmod"&gt; &nbsp; &lt;option value="zero"&gt;-&lt;/option&gt; &nbsp; &lt;option value="d6"&gt;Pistol&lt;/option&gt; &nbsp; &lt;option value="d8"&gt;Submachine Gun&lt;/option&gt; &nbsp; &lt;option value="d12"&gt;Sniper Rifle&lt;/option&gt; &nbsp; &nbsp; &lt;/select&gt; &lt;button id="rollButton"&gt;Roll Dice&lt;/button&gt; You should read the wiki link I included above.&nbsp; ;-P The wiki will explain how your button's should be formatted to work with roll20.&nbsp; Also a must read; <a href="https://wiki.roll20.net/Building_Character_Sheets" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets</a> and GiG's website that includes everything you'll need to build sheets for roll20; <a href="https://cybersphere.me/roll20-sheet-author-master-list/" rel="nofollow">https://cybersphere.me/roll20-sheet-author-master-list/</a> Your button isn't named and is missing a value, so it does nothing as-is. ;-( To just get a roll out of the select and your button. (this works for one roll.&nbsp; You'll need to modify the attribute and button names to be unique for your other attacks) &lt;select name="attr_rollmod1"&gt; &nbsp; &lt;option value="zero" selected&gt;-&lt;/option&gt; &nbsp; &lt;option value="[[d6]]"&gt;Pistol&lt;/option&gt; &nbsp; &lt;option value="[[d8]]"&gt;Submachine Gun&lt;/option&gt; &nbsp; &lt;option value="[[d12]]"&gt;Sniper Rifle&lt;/option&gt;&nbsp;&nbsp; &nbsp; &lt;/select&gt; &lt;button type="roll" name="roll_weapon1" value="@{rollmod1}"&gt;Roll Dice&lt;/button&gt;
Amazing! You're a star!