I have a Radio button that I want to ‘check’ if a value matches a value in a comma separated list which comes from a database field. This needs to be done at the Input field and so I cannot use the IN function of a Query. This is what I have tried so far but doesn’t work.
dmx-bind:checked="specialist_id == sc_ad_job_q.data.sa_q_job_q[0].meth_specialist_ref.split(',')"
where
and
meth_specialist_ref = 34_1,33_1,32_3
If I do a simple
dmx-bind:checked="specialist_id == '33_1'"
then it works fine
Teodor
February 28, 2020, 12:10pm
2
Have you tried:
sc_ad_job_q.data.sa_q_job_q[0].meth_specialist_ref.contains(specialist_id)
Hi @Teodor , I hadn’t tried that before (not sure why?) but have just tried it now and it gives good results so far. I think that has done the trick.
One question though, if the specialist_id was 3_1 instead of 33_1, would the result be true or false? I’m hoping false.
where
and
meth_specialist_ref = 34_1,33_1,32_3
** EDIT **
I have just checked and it IS a problem, it returns TRUE!
How can I have an exact match rather than a simple contains within?
Hi @Teodor , do you have any further thoughts on this problem?
patrick
February 28, 2020, 9:37pm
5
A mix of your try and Teodors solution should solve your problem
sc_ad_job_q.data.sa_q_job_q[0].meth_specialist_ref.split(',').contains(specialist_id)
1 Like
Brilliant! That works
Thanks @patrick , I would have struggled to work that out myself, so great to learn something new from the experts.