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

radio button values and sheetworkers

1461359250
Phoxounet
Sheet Author
Translator
Hi there ! I am not a html or javascript expert developper. I am just trying to build a sheet for friends of mine. The game is Warhammer 2. I have radio buttons to adjust skills levels. The html code is ok. Anyway, I have a problem with the script. The event listener on the variable changes associated with the radio buttons is ok. Here is the html code : <div> <div style="margin-left:10px;width:140px;">Canotage</div> <divstyle="width:30px;margin-left:1px;font-weight:lighter;" >(F)</div> <input type="radio" name="attr_canot" value="1" style="margin-left:15px;" checked/> <!--1/2--> <input type="radio" name="attr_canot" value="2"/> <!-- acquis--> <input type="radio" name="attr_canot" value="3" style="margin-left:20px;"/> <!-- +10%--> <input type="radio" name="attr_canot" value="4"style="margin-left:23px;"/> <!-- +20% --> <input type="text" value="0" name="attr_canot_total" style="width:40px;height:18px;background:black;margin-left:25px;"/> <divstyle="width:10px;margin-left:1px;" >%</div> </div> and the script : on("change:F_Actuel change:canot ", function() { getAttrs(["F_Actuel", "canot", "canot_total"], function(values) { if(canot == '1' ){setAttrs({canot_total: Math.floor(parseInt(values.F_Actuel,10) / 2 )});} else if(canot == '2' ){setAttrs({canot_total: parseInt(values.F_Actuel,10) });} else if(canot == '3' ){setAttrs({canot_total: parseInt(values.F_Actuel,10)+10 });} else {setAttrs({canot_total: parseInt(values.F_Actuel,10)+20 });} }); }); I checked the event listener using the following script : on("change:F_Actuel change:canot ", function() { getAttrs(["F_Actuel", "canot_total"], function(values) { setAttrs({canot_total: Math.floor(parseInt(values.F_Actuel,10) / 2 ) }); }); }); The event listener checker script works as intended. Anyway, I can't get the skills adjusting script to work. Nothings happens when I use it. The rest of the script keeps working as intended so sheetworkers are not affected by a nasty syntax error. From what I guess, the conditional is the problem.  Any help would be welcomed. Regards, Phoxounet
1461401138
Lithl
Pro
Sheet Author
API Scripter
You're checking "if(canot == '1')", etc. but there is no "canot" variable defined. You want to use "values.canot".
1461401462
Phoxounet
Sheet Author
Translator
Ho my god.... this is a so stupid and nasty error.... Many many thanks, Brian. Shame on me :p Regards :)