Page 1 of 1

Display 'select' values in Browse Form

Posted: Wed Nov 17, 2021 10:15 pm
by Marvo
Hi

I have a select field, with the options created in list, e.g. 0|Male|1|Female
This works fine in the Edit form

On the Browse form though, the values are shown as 0 or 1 rather than showing Male or Female

How to display the Male/Female on the browse screen and not the list 'index #'

Thanks

Re: Display 'select' values in Browse Form

Posted: Wed Nov 17, 2021 11:36 pm
by klasyc
Hi Marvo,

open the form properties, select the Browse tab and wrap your gender column name by the IF SQL statement (https://www.w3resource.com/mysql/contro ... nction.php):

Code: Select all

IF(gender = 0, "Male", "Female")
The next possibility would be probably the custom PHP code in Before Browse action.

Hope this helps :)

Re: Display 'select' values in Browse Form

Posted: Wed Nov 17, 2021 11:54 pm
by Marvo
Thank you! That worked! However, I have other select fields that 5 or 6 options in the list. I can't use IF this. .... else this...

Is there a similar SQL statement that checks multiple values
if it's 1 then this, if it's 2 then this, if it's 3 then this, if it's 4 then this .........

Thank you!

Re: Display 'select' values in Browse Form

Posted: Thu Nov 18, 2021 1:08 am
by kev1n
Either replace the list with an SQL that pulls the values from a table and then use a join in the browse to retrieve the description for the values or use multiple replace() like

Code: Select all

REPLACE(REPLACE(REPLACE(your_column, '1', 'One'),'2','Two'),'3','Three')

Re: Display 'select' values in Browse Form

Posted: Thu Nov 18, 2021 1:08 pm
by Marvo
Thank you - sorted!