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

select field and values

1461842942

Edited 1461843580
Phoxounet
Sheet Author
Translator
Hi there. I have an issue with a select field and I don't see what it is. here are pieces of code I made for my sheet. <div style="width:75px;margin-left:2px;text-align:center;font-size:18px;">Actuel :</div> <input type="text" value="0" name="attr_CC_Actuel" /> <input type="text" value="0" name="attr_CT_Actuel"/> <input type="text" value="0" name="attr_F_Actuel" /> <input type="text" value="0" name="attr_E_Actuel"/> <input type="text" value="0"name="attr_Agi_Actuel"/> <input type="text" value="0" name="attr_Int_Actuel"/> <input type="text" value="0"name="attr_FM_Actuel"/> <input type="text" value="0" name="attr_Soc_Actuel"/> </div> <div> <input type="text" name="attr_comp1_name"style="margin-left:5px;width:177px;"/> <select name="attr_comp1_carac" style="width:30px;margin-left:1px;font-weight:lighter;"> <option value="@{F_Actuel}">F</option> <option value="@{Agi_Actuel}">Agi</option> <option value="@{Int_Actuel}">Int</option> <option value="@{Soc_Actuel}">Soc</option> <option value="@{FM_Actuel}">FM</option> </select> <input type="text" name="attr_comp1_carac"style="width:30px;margin-left:1px;font-weight:lighter;"/> <input type="radio" name="attr_comp1" value="2" checked /> <!-- acquis--> <input type="radio" name="attr_comp1" value="3" style="margin-left:23px;"/> <!-- +10%--> <input type="radio" name="attr_comp1" value="4"style="margin-left:26px;"/> <!-- +20% --> <input type="text" value="0" name="attr_comp1_total" style="width:40px;height:18px;background:black;margin-left:19px;"/> <divstyle="width:10px;margin-left:1px;" >%</div> </div> the line below is a temporary check line. It should return the value of the attribute selected in the select field. <input type="text" name="attr_comp1_carac"style="width:30px;margin-left:1px;font-weight:lighter;"/> However, it is not working. It returns raw text from the value part of the options line. I've searched in other sheets and I don't see what the issue is. I've tried to remove the check line (because of possible conflict having twice the same attribute name but it is still not working. I have a sheetworker that set attr_comp1_total based of previous values and selections. If I use a text input instead of the select field, the sheetworker works as intended. If there is the select field, it returns Nan (so I guess a value is not read as number, even with a parseInt()... I changed  the input type of "F_Actuel" from text to number and it is still not working... Plz help :) Regards :)
1461866880
Lithl
Pro
Sheet Author
API Scripter
Your comp1_carac text field is giving you the raw text of your option values because that is  the value of the option. If you want to display the calculated value, you need to make the input an autocalc field by making it disabled. (I would also strongly recommend changing the input's name in that case, as well.) <select name="attr_comp1_carac" style="width:30px;margin-left:1px;font-weight:lighter;"> <option value="@{F_Actuel}">F</option> <option value="@{Agi_Actuel}">Agi</option> <option value="@{Int_Actuel}">Int</option> <option value="@{Soc_Actuel}">Soc</option> <option value="@{FM_Actuel}">FM</option> </select> <input type="text" name="attr_comp1_carac_value" value="@{comp1_carac}" disabled="disabled" style="width:30px;margin-left:1px;font-weight:lighter;"/> Unfortunately, that doesn't solve your problem with the sheet worker script. The value of @{comp1_carac} is  "@{...}", and the value of @{comp1_carac_value}" above is  "@{comp1_carac}". You could do something like this in your sheet worker to get the value: getAttrs(['comp1_carac'], function(values) { getAttrs([values.comp1_carac.substring(2, calues.comp1_carac.length - 1)], function(v) { var comp1_carac_value = _.toArray(v)[0]; // comp1_carac_value will be the value of one of @{F_Actuel}, @{Agi_Actuel}, etc. }); });
1461910032

Edited 1461910551
Phoxounet
Sheet Author
Translator
Haaa I got it : the select value only returns raw text that needs to be parsed into values with a calculated value in an autocalc field  ^^ As autocalculated fields need to be disabled to be calculated, I can't directly use it in the sheetworkers. Anyway, it is a small part of the sheet. I could used an autocalculated field for the comp1_total. It would be simplier. Thx you for helping :) Regards :)