Aaron
Posts: 145
|
Posted: 07/06/2011, 9:09 AM |
|
Hello all,
I'm using CCS 3.2 with mysql and php. I'm trying to change returned data values on page load, but I'm unsure of the best way to accomplish this. The database is returning values from a survey. People have answered, yes, no or no answer at all. These are stored as 1 (yes), 2 (no) or null/empty for no answer. So, instead of displaying these 1, 2, etc I wanted to have the page convert them to human readable answers. Is there an easy way to do this or am I looking at custom code on every label for the conversion?
Thanks,
Aaron
|
|
|
jjrjr2
Posts: 131
|
Posted: 07/06/2011, 10:24 AM |
|
If you are using a YES/NO table for your radio buttons or list box on the form to populate the database you are half way there.
If not create a yes_no table with 2 fields. Have one colomn hold the 1/2 value another colomn contain the coresponding text for that value
eg:
row 1 the values might be 1 - yes
row 2 the values ----- 2 - no.
Now just add that table to to your Query thru query builder and join the value in your form to the numeric table in the yes_no table..
Now, in your label, make the datasource the text field from the yes_no table.
This way no custom coding or DLookups needed.
Hope that helps
John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
|
|
Aaron
Posts: 145
|
Posted: 07/06/2011, 10:28 AM |
|
I'm not actually using a YES/NO table for the radio buttons. They are hard-coded as 1 or 2 depending on selection. The database is set to be an integer. I guess I could create such a table for this and future use.
Thanks for the idea!
Aaron
|
|
|
jjrjr2
Posts: 131
|
Posted: 07/06/2011, 10:46 AM |
|
Yup
Just create a yes no table & join it in Query Builder.
Just put the text value from your new table into the label you want yes/no text
Sould be very easy & no Custom coding or DLookups will be needed for all the labels.
Anymore, when ever I start a project, there are a set of standard tables I start with.
One is always a YES / NO Table.. It can be used for all record fields in radio buttons or list box in a CCS record form..
Also it allows me to easily do exactly what you are wanting to do. (I more often do a DLookup on the Yes No table.
I also Create a Groups table for security groups for the same reason. I can display the group name rather than the group number very easily.
Also, by doing this, changes to group names or muti language sites become DB maintenance not hunting in the code.. You only have to modify the tables rather than searchiing & having to change all the code.. It is simple DB changes.
Makes life alot easier.
John
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
|
|
datadoit
|
Posted: 07/06/2011, 12:12 PM |
|
For the label control, set the Data Type to Boolean. Choose the Format
you want - in this case specify Yes;No. Then specify the DBFormat of
1;2. All one's will display as Yes. All two's will display as No.
|
|
|
Aaron
Posts: 145
|
Posted: 07/13/2011, 6:53 AM |
|
datadoit ... that's what I was looking for! It had been so long since I'd used it I had forgotten exactly how. Thanks!
|
|
|
|