checkboxes... troubling me again!

5 posts by 4 authors in: Forums > CMS Builder
Last Post: February 24, 2011   (RSS)

By Deborah - August 4, 2010

Those pesky checkbox fields cause me continual grief. I have tried every combination of code used successfully on other projects ((sigh)), and yet I can't figure out where I've gone wrong here. I either see the last three records entered (with disregard to the "favorite blog" checkbox, or I see no records at all.)

I have a checkbox field named favorite_blog with field values of Yes and No.

Header code:
list($blogRecordsFav, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'limit' => '3',
'allowSearch' => false,
'where' => " favorite_blog LIKE '%\Yes\t%' ",
));

HTML code:
<ul>
<?php foreach ($blogRecordsFav as $record): ?>
<li><a href="<?php echo htmlspecialchars ($record['_link']) ?>"><?php echo htmlspecialchars ($record['title']) ?>
<?php foreach ($record['favorite_blog_photo'] as $upload): ?>
<img src="<?php echo htmlspecialchars ($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a></li>
<?php endforeach ?>
<?php endforeach ?>
</ul>

The above code displays nothing. Is there anything obviously wrong? (a v2.4 site, by the way)

Would sincerely appreciate any assistance.
~ Deborah

Re: [chris] checkboxes... troubling me again!

By Deborah - August 4, 2010

Hey, Chris.

I tried that 'where' code snkppet earlier today, but it was obviously in conflict with something else I had going (or not going) with the HTML code then.

All working great now. Thanks so much for your quick response!

~ Deborah

Re: [Deborah] checkboxes... troubling me again!

hate to revive an old post but this was killing me.
I had to change a regular list option into a multiple select checkbox list for a client.
I made the usual 'where' call above the head tag for 'Monday'.
Then I was pulling my hair out until I found this old post and came up with the answer.

'where' => "day_of_week2 LIKE '%\Monday\t%' ",

You guys should put that in the Documentation.
[crazy]

Re: [sublmnl] checkboxes... troubling me again!

By Jason - February 24, 2011

Hi,

You'll want to make sure you have tab characters on either side of your value like this:

'where' => "day_of_week2 LIKE '%\tMonday\t%' ",

Thanks for the suggestion. We'll looking into adding some more information on how these lists work.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/