PDA

View Full Version : Custom Profile Field Multiple Selection Checkbox


Abhik
02-06-2012, 01:07 PM
Hello,
I have a multiple selection checkbox user field where I have 10 options. I have limited maximum 5 options can be checked.

Now, I want to show only the checked options (even if the number of checked options are below 5) in postbit. How can I do that?

<vb:if condition="$post['field9'] & 1">Option 1</vb:if>
<vb:if condition="$post['field9'] & 2">Option 2</vb:if>
<vb:if condition="$post['field9'] & 3">Option 3</vb:if>
<vb:if condition="$post['field9'] & 4">Option 4</vb:if>
<vb:if condition="$post['field9'] & 5">Option 5</vb:if>
<vb:if condition="$post['field9'] & 6">Option 6</vb:if>
<vb:if condition="$post['field9'] & 7">Option 7</vb:if>
<vb:if condition="$post['field9'] & 8">Option 8</vb:if>
<vb:if condition="$post['field9'] & 9">Option 9</vb:if>
<vb:if condition="$post['field9'] & 10">Option 10</vb:if>

That seems to return the options randomly even if the option is not checked.

kh99
02-06-2012, 01:11 PM
Each option corresponds to one bit, so each mask you '&' with the value has to be a single bit. So the mask values should be 1, 2, 4, 8, 16, 32, 64, 128, 256, 512.

Lynne
02-06-2012, 05:35 PM
See this - Using your User Profile Fields in your postbit templates (w/ all plugin method) (https://vborg.vbsupport.ru/showthread.php?t=250418)