[SOLVED] calc condition if ...

Status
Not open for further replies.

futurlive

New Member
I still ask for help:
i use in a calc field:
if ({_classi___of_strum_mus} == 3) {return 6;
}
else {
return 0;
}


the field {_classi___of_strum_mus} is a checkbox of values, for example: ["1", "2", "3"]. == is wrong; what is the right parameter for contains?
always thanks
 
thanks for collaboration
unfortunately it does not work for me
the content of the field is, for example, ["1", "2", "3", "5"]
I think the problem is ... ($ checkbox == 3)
it's not == but ... like .. it contains
 
This work for me.
I don't know why not work in your situation.
If you want to check string for specific number try this:
PHP:
$checkbox = '{_classi___of_strum_mus_raw}';
if (strpos($checkbox, '3') !== false) {
    return 6;
}
else {
    return 0;
}
 
thanks, I will do other tests
surely I'm wrong
I attach some image
 

Attachments

  • element AB56.jpg
    element AB56.jpg
    56.5 KB · Views: 127
  • element of_strum_mus.jpg
    element of_strum_mus.jpg
    112.9 KB · Views: 149
  • elementi lista.jpg
    elementi lista.jpg
    182.8 KB · Views: 121
  • lista.jpg
    lista.jpg
    38.5 KB · Views: 146
I saw your pictures and I don't understand your scenario, but you did not use my code correctly.
Add _raw to element name. Without this the variable $checkbox contains checkbox name instead of value.
 
As in @startpoint's code you must quote placeholders and strings.
Make sure you don't have typos and use var_dump(...);exit; or the jdump extension to debug what you really get.
Not sure if table names starting with "_" may break anything.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top