keith1995
09-20-2007, 05:09 PM
Anyone familar with vBulletin and the binary values it assigns to multi-select checkboxes?
We are developing a vBulletin site with a member profile subcomponent and are using the multi-select checkboxes for two form fields. vBulletin stores the values of the selected checkboxes as a binary value, using the "to the xth power" and I don't quite know how to decode that so we can display which checkboxes are selected in the member profile.
vBulletin has its own member profile system but we'd like to create one outside of its template system which is why we need to try and decode these values.
For example, we have the following field (its value is in paratheses):
Geographical Areas:
Northeast (1)
Mid-Atlantic (2)
Southeast (4)
Midwest (8)
Southwest (16)
West Coast (32)
Canada (64)
China (128)
India (256)
Europe (512)
South America (1024)
Other (2048)
As I'm sure you are aware, the values are determined by taking the checkbox's number and times it to the 2nd power.
The problem is that vBulletin adds up the values of the selected checkboxes and stores that number. For example, 67 would mean that Northeast, Mid-Atlantic and Canada were selected.
Anyone know how to decode this value using PHP so I can display which checkboxes are selected?
We are developing a vBulletin site with a member profile subcomponent and are using the multi-select checkboxes for two form fields. vBulletin stores the values of the selected checkboxes as a binary value, using the "to the xth power" and I don't quite know how to decode that so we can display which checkboxes are selected in the member profile.
vBulletin has its own member profile system but we'd like to create one outside of its template system which is why we need to try and decode these values.
For example, we have the following field (its value is in paratheses):
Geographical Areas:
Northeast (1)
Mid-Atlantic (2)
Southeast (4)
Midwest (8)
Southwest (16)
West Coast (32)
Canada (64)
China (128)
India (256)
Europe (512)
South America (1024)
Other (2048)
As I'm sure you are aware, the values are determined by taking the checkbox's number and times it to the 2nd power.
The problem is that vBulletin adds up the values of the selected checkboxes and stores that number. For example, 67 would mean that Northeast, Mid-Atlantic and Canada were selected.
Anyone know how to decode this value using PHP so I can display which checkboxes are selected?