when checkbox used a "1" displays next to item

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 28, 2008   (RSS)

By Codee - March 27, 2008 - edited: March 30, 2013

Dave and Co,

On our clients site we have a series of checkboxes used to display a field or not. The checkbox system works great EXCEPT when a box is checked and it displays the field name it also displays a "1". We would only like the field name to display.

Example: Let's say the record input person is loading a record for a piece of motorized equipment. We have 2 checkboxes - one for "diesel" and one for "gas". The input person chooses "diesel". When the visitor sees the listing for the record, they see "diesel: 1".

Thanks in advance!

Re: [equinox69] when checkbox used a "1" displays next to item

By Dave - March 27, 2008

Hi Terry,

There's a few options for that.

If you want to show some text if a checkbox (named 'feature') is checked, you could use this:

<?php if ($record['feature']): ?>Feature Name<?php endif ?>

Or if you wanted to display two different values such as "Yes" or "No" you could use some code like this:

<?php echo $record['feature'] ? "Yes" : "No"; ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com