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

Javascript into working worker script?

So I did a thing:&nbsp; <a href="https://www.w3schools.com/code/tryit.asp?filename=" rel="nofollow">https://www.w3schools.com/code/tryit.asp?filename=</a>.. for a sheet I'm working on, with 0 knowledge whatsoever about JS, API and worker scripts aaaand turned out it won't work in my sheet due to site's security reasons and JS policy which I didn't know about. Is there any kind JS mage that can help me make this work on roll20 as worker script or tell me if it's even possible? I've spend way too much time struggling to even come up with this thing which I'm pretty sure could be done way simpler and I'm on a point of breaking and giving up.
Is the dropdown intended to display in another part of the sheet?
1495921141
Lithl
Pro
Sheet Author
API Scripter
Don't include id attributes in your sheet. Ids need to be unique across a page, but your HTML is duplicated for each character in the campaign. Name attributes need to start with "attr_" to be useful. You cannot set onclick handlers to call your JavaScript functions optgroup is not a tag with an optional closing tag. You're missing &lt;/optgroup&gt;. Readonly is a meaningless attribute for an optgroup. Sheet workers cannot modify HTML attributes, so you cannot enable/disable option elements in your select. I'm not certain what goal you're actually attempting to achieve, but a skeleton of a sheet worker that would function for you is: Known forms:&lt;br&gt; &lt;input type="checkbox" name="attr_form1" value="1"&gt; Shii-Cho&lt;br&gt; &lt;input type="checkbox" name="attr_form2" value="2"&gt; Makashi&lt;br&gt; &lt;input type="checkbox" name="attr_form3" value="3"&gt; Soresu&lt;br&gt; &lt;input type="checkbox" name="attr_form4" value="4"&gt; Ataru&lt;br&gt; &lt;input type="checkbox" name="attr_form5" value="5"&gt; Shien&lt;br&gt; &lt;input type="checkbox" name="attr_form6" value="6"&gt; Niman&lt;br&gt; &lt;input type="checkbox" name="attr_form7" value="7"&gt; Juyo&lt;br&gt; &lt;br&gt;&lt;br&gt; Using form:&lt;br&gt; &lt;select name="attr_forms" &gt; &nbsp; &lt;optgroup label="Using form:"&gt; &nbsp; &lt;option value="..."&gt;None&lt;/option&gt; &nbsp; &lt;option value="1"&gt;Schii-Cho&lt;/option&gt; &nbsp; &lt;option value="2"&gt;Makashi&lt;/option&gt; &nbsp; &lt;option value="3"&gt;Soresu&lt;/option&gt; &nbsp; &lt;option value="4"&gt;Ataru&lt;/option&gt; &nbsp; &lt;option value="5"&gt;Shien&lt;/option&gt; &nbsp; &lt;option value="6"&gt;Niman&lt;/option&gt; &nbsp; &lt;option value="7"&gt;Juyo&lt;/option&gt; &lt;/optgroup&gt; &lt;/select&gt; &lt;script type="text/worker"&gt; on('change:form1 change:form2 change:form3 change:form4 change:form5 change:form6 change:form7', function() { getAttrs(['form1', 'form2', 'form3', 'form4', 'form5', 'form6', 'form7'], function(values) { _.each(values, (v, k) =&gt; values[k] = parseInt(v) || 0); // values.form1 === 1 or 0, values.form2 === 2 or 0, values.form3 === 3 or 0, etc. setAttrs({ // this isn't the result you want (I don't know what result you want), just an example of using setAttrs forms: Math.max.apply(null, _.values(values)), }); }); }); &lt;/script&gt;
1495922845

Edited 1495923535
As&nbsp;Rabulias said, the drop-down menu will be in different &nbsp;part of the sheet. I want the all options in the drop-down menu to be grayed out, not for use, until particular lightsaber form (or few of them) is checked in the checkbox above. In the link to the JS i wanted to use it was pretty simple.. I think. It was supposed to check on click if the checkbox is checked, if yes then it would remove "disabled" from html in the corresponding option in the drop-down menu, and if not then it would add it back. But since I can't use the functions I wanted since they're limited and disabled I have no idea how to do it. It took me quite a bit of time to figure out how to do it the way I did it in the link, I literally started with JS today. "Sheet workers cannot modify HTML attributes, so you cannot enable/disable option elements in your select." - So.. that's pretty much no. Well, I guess that was a good attempt, I learned something new from it. Thank You for Your help, much apprecitatred!&nbsp;