inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Feb 5, 2016 11:31:18 GMT -8
I'm updating one of my plugins and have added a checkbox. The variable name for this checkbox is msg_nf_lbr. Would this if statement run if the checkbox was ticked?
if (bool(msg_nf_lbr))
If this is not the way, would someone please point me in the right direction? Since I really only need a true (checked) or false (not checked) check for this, I thought the bool would be what I needed for this.
Thanks!
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Feb 5, 2016 16:46:08 GMT -8
The Selection Box allows the user to select from a list of premade options as you've said but the format in which it returns data depends on whether you have it set to select multiple options or only one option at a time. In the single answer mode it gives you the value of whatever was chosen. So if the user chose option2 then proboards.plugin.get('plug_in_name').settings.premade_image would return a string with the value of "answer2". If you however set multiple to yes then the user can select more than one answer so the values are returned in an array (e.g. ["answer1", "answer2"]). If the user selects no answer then the variable would be undefined or an empty string in single answer mode or an empty array in multiple answer mode. Keep this in mind since an empty array wouldn't evaluate to a boolean false like undefined or an empty string would. Ignore the fact that in the image above it is set to Selection Box, it is exactly the same as far as data handling is concerned. You would basically test for the value that you set in the "value" column to see if that specific option was selected by the user. In single answer mode that value would be returned as a string and in multiple answer mode it is returned as an array of strings. msg_nf_lbr === 'answer1' //single answer mode msg_nf_lbr.indexOf('answer1') !== -1 //multiple answer mode
$.inArrayLooose('answer1',msg_nf_lbr) != -1 /*Proboard's way for older browsers that may not support Array.prototype.indexOf this custom Proboards way also allows for loose type checking since ["1","2","3"].indexOf(1) would return -1 (numbers and strings aren't same type )*/
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Feb 6, 2016 14:39:20 GMT -8
|
|