CHECKBOXES NOT WORKING!

15 posts by 4 authors in: Forums > CMS Builder
Last Post: April 3, 2010   (RSS)

I've been trying to resolve this problem since November 9th with Interactive Tools Tech Support... I am desparately trying to simply have Checkboxes that, when checked, DISPLAY AN ICON [gif,png or jpeg]... The info I was given on 11/9 was as follows.....

"Or, to have an image appear instead, you would have something like this (this is assuming you leave the Checked values as the default 1, and change Unchecked to be blank):

<?php if ([url "mhtml:{F7CB687F-879E-4447-AB5C-FFB92CE9C191}mid://00000052/!x-usc:mailto:!@$photolinkRecord['pet_friendly'"]!@$photolinkRecord['pet_friendly'[/#0066cc][/url]]) ?><img src="your-image-here.jpg"><?php endif ?>

First of all, if I place <?php endif ?> at the end as indicated above, the entire page is BLANK online!

NOTE: At that time the name of the Section was photolink.

Below please find a COPY of the code I have inserted into a page where[/#000000] the name of the Section is mountsnow_skierlodging [/#ff0000]<?php if ([url "mailto:!@$mountsnow_skierlodgingRecord['indoor_pool'"]!@$mountsnow_skierlodgingRecord['indoor_pool'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_indoor_pool.gif" alt="Indoor Pool" />

Note... [/#ff0000]I have the code for 9 additional icons inserted below this one. WITH THIS CODE, ALL 10 ICONS ARE DISPLAYED, [/#ff0000]regardless of what is listed in the CHECKED VALUE line on the form..[/#000000] eg 1, 0, blank, Indoor Pool, whatever. And this is with the UNCHECKED VALUE of blank or 0.

And, again, if I place <?php endif ?> at the end as indicated above, the entire page is blank online!

I will more than appreciate someone advising me of what I am doing wrong so that I can finally place the page containing these icons online.

Re: [weblinks] CHECKBOXES NOT WORKING!

By gkornbluth - November 29, 2009 - edited: November 29, 2009

Hi Weblink,

If I understand you correctly, you have a single record section editor with a checkbox field called indoor_pool.

If that's true, you might try this:

<?php if ($mountsnow_skierlodgingRecord['indoor_pool'] == '1'): ?>
<img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_indoor_pool.gif" alt="Indoor Pool" />
<?php else: ?> ...your code...
<?php endif ?>


You can remove the line <?php else: ?> ...your code... if you don't want to do something else if the checkbox is not checked.

I'd search for another <?php endif ?> and make sure that there isn't a rogue code snippet lurking somewhere in your code.

See where you get and post back here.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] CHECKBOXES NOT WORKING!

Jerry...

I can't thank you enough for your quick reply. I'm realy hurting on this one.

Unfortunately, I should have been more explicit... No, I have a number of icons for different services to be displayed on the same page... and, I have been working on the code again since posting the message. The present code is pasted below...

<?php if ([url "mailto:!@$mountsnow_skierlodgingRecord['wifi'"]!@$mountsnow_skierlodgingRecord['wifi'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_wifi.png" alt="Wifi" /><?php endif ?><?php endforeach; ?>

&nbsp;<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['vacation_packages'"]!@$mountsnow_skierlodgingRecord['vacation_packages'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_vacationpackages.gif" alt="Vacation Packages
"/><?php endif ?><?php endforeach; ?> &nbsp;

<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['fireplace'"]!@$mountsnow_skierlodgingRecord['fireplace'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_fireplace.gif" alt="Fireplace" /><?php endif ?><?php endforeach; ?> &nbsp;

<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['dining'"]!@$mountsnow_skierlodgingRecord['dining'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_dining.gif" alt="Dining" /><?php endif ?><?php endforeach; ?> &nbsp;
<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['children_welcome'"]!@$mountsnow_skierlodgingRecord['children_welcome'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_familyfriendly.gif" alt="Children Welcome" /><?php endif ?><?php endforeach; ?> &nbsp;
<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['cell_phone_coverage'"]!@$mountsnow_skierlodgingRecord['cell_phone_coverage'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_cellphone.png" alt="Cell Phone Coverage" />
<?php endif ?><?php endforeach; ?> &nbsp;
<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['pool'"]!@$mountsnow_skierlodgingRecord['pool'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_pool.gif" alt="Outdoor Pool" />
<?php endif ?><?php endforeach; ?> &nbsp;
<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['indoor_pool'"]!@$mountsnow_skierlodgingRecord['indoor_pool'[/url]]) ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_indoor_pool.gif" alt="Indoor Pool" />
<?php endif ?><?php endforeach; ?> &nbsp;
<?php elseif ([url "mailto:!@$mountsnow_skierlodgingRecord['pet_friendly'"]!@$mountsnow_skierlodgingRecord['pet_friendly'[/url]]) ?>
<img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_petfriendly.png" alt="Pet Friendly" /><?php endif ?><?php endforeach; ?> &nbsp;
<?php else ([url "mailto:!@$mountsnow_skierlodgingRecord['wheelchair_accessible'"]!@$mountsnow_skierlodgingRecord['wheelchair_accessible'[/url]]) ?><img src=" http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_wheelchairaccessible.png" alt="Wheelchair Accessible"><?php endif ?>

</b></font color="9933FF"> <span class="x-small"></span><br><br>
</p>
<hr align="center" width="475" noshade="noshade"/>
<p>
<?php endforeach; ?>
<?php if (!$mountsnow_skierlodgingRecords): ?>
No records were found!<br/>

<?php endif ?

As I'm sure you can tell, I am not a tech person... I'm brain dead when it comes to some code... I'm a designer... I tried to follow what you had originally posted and obviously messed it up Anything you can do to help me clear up the above code will be appreciated. You can view the page online WITH ALL OF THE ICONS [OBVIOUSLY NOT THE RESULT OF CHECKBOXES] to see what I am trying to accomplish.. Of course the purpose is for the advertiser to check the checkboxes appropriate to his or her business so that the appropriate icons are displayed. Here's the TEST PAGE address... http://www.linkvermont.com/skierlodging_mountsnow.php

Best,

Bob

Re: [gkornbluth] CHECKBOXES NOT WORKING!

Jerry...

I did it again.... the web page address I gave you now only takes you to a blank page... SORRY!

Bob

Re: [weblinks] CHECKBOXES NOT WORKING!

By Chris - November 30, 2009

Hi weblinks,

Wow! That's a colourful post! I actually had trouble reading it with all that markup.

I think you're missing a colon in your IF statement. From your first post, this:

<?php if (!@$photolinkRecord['pet_friendly']) ?><img src="your-image-here.jpg"><?php endif ?>

should be:

<?php if (!@$photolinkRecord['pet_friendly']): ?><img src="your-image-here.jpg"><?php endif ?>

That missing colon would cause a parse error, and if your web server is not configured to output errors to the web browser, you might only see a blank page. You may want to contact your web hosting provider and ask them how you can see PHP errors. Debugging a script without being able to see specific errors is difficult, even for experienced web developers.

In your second post I noticed that you have <?php endforeach; ?> copied quite a few times. There should only be one endforeach (per foreach) and it should be at the bottom of your record display code. Having extra endforeach's would also cause parse errors (i.e. blank pages.) Also, since these are all separate tests, you'll want to use ifs, not elseifs. Additionally, the ! symbol in your if condition means "not" and will cause your image to be displayed if the checkbox is not checked. The @ symbol will supress errors, but any errors you get will provide valuable clues about what's going wrong, so you definitely don't want to supress errors.

Try this code instead:

<?php if ($mountsnow_skierlodgingRecord['wifi']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_wifi.png" alt="Wifi" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['vacation_packages']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_vacationpackages.gif" alt="Vacation Packages" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['fireplace']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_fireplace.gif" alt="Fireplace" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['dining']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_dining.gif" alt="Dining" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['children_welcome']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_familyfriendly.gif" alt="Children Welcome" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['cell_phone_coverage']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_cellphone.png" alt="Cell Phone Coverage" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['pool']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_pool.gif" alt="Outdoor Pool" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['indoor_pool']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_indoor_pool.gif" alt="Indoor Pool" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['pet_friendly']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_petfriendly.png" alt="Pet Friendly" /><?php endif ?>
<?php if ($mountsnow_skierlodgingRecord['wheelchair_accessible']): ?><img src="http://www.linkvermont.com/PAGE_LAYOUTS_Layer_Images/icon_wheelchairaccessible.png" alt="Wheelchair Accessible"><?php endif ?>

</b></font color="9933FF"> <span class="x-small"></span><br><br></p><hr align="center" width="475" noshade="noshade"/><p>
<?php endforeach; ?>
<?php if (!$mountsnow_skierlodgingRecords): ?>
No records were found!<br/>
<?php endif ?>


If that doesn't work, try outputting your checkbox fields to make sure they're 0s and 1s like you're expecting:

wifi = <?php echo $mountsnow_skierlodgingRecord['wifi'] ?><br />
vacation_packages = <?php echo $mountsnow_skierlodgingRecord['vacation_packages'] ?><br />
fireplace = <?php echo $mountsnow_skierlodgingRecord['fireplace'] ?><br />
dining = <?php echo $mountsnow_skierlodgingRecord['dining'] ?><br />
children_welcome = <?php echo $mountsnow_skierlodgingRecord['children_welcome'] ?><br />
cell_phone_coverage = <?php echo $mountsnow_skierlodgingRecord['cell_phone_coverage'] ?><br />
pool = <?php echo $mountsnow_skierlodgingRecord['pool'] ?><br />
indoor_pool = <?php echo $mountsnow_skierlodgingRecord['indoor_pool'] ?><br />
pet_friendly = <?php echo $mountsnow_skierlodgingRecord['pet_friendly'] ?><br />
wheelchair_accessible = <?php echo $mountsnow_skierlodgingRecord['wheelchair_accessible'] ?><br />


I hope this helps. If you still can't get this working and the error logs aren't helping you, you can always get our consulting department to fix things up for you: http://www.interactivetools.com/consulting/index.php
All the best,
Chris

Re: [chris] CHECKBOXES NOT WORKING!

Chris...

Thanks much for the totally understandable reply!!!!!

I followed every one of your instructions including the output of 0's and 1's... Still No Luck...

Unfortunately, I'm now getting Error Messages on this TEST PAGE http://www.linkvermont.com/skierlodging_mountsnow.php Hopefully the Error Messages will help you give me a solution... I'm going to wind up in a padded room if I don't get this working online. PLEASE get back to me asap.

Regards,

Bob

Re: [weblinks] CHECKBOXES NOT WORKING!

By Chris - December 1, 2009 - edited: December 1, 2009

Hi Bob,

Okay, great. This error message is something we can work with:

Notice: Undefined variable: mountsnow_skierlodgingRecord in /netapp/whnas-swamp/s10/s10/01575/www.linkvermont.com/webdocs/skierlodging_mountsnow.php on line 212


This tells us that your code refers to $mountsnow_skierlodgingRecord, but that variable hasn't been defined. That's probably because the variable has a different name (such as $record.)

Please post (as an attachment is best) the complete PHP source code for your skierlodging_mountsnow.php page. I'll have a look at it and be able to tell you what you need to change.
All the best,
Chris

Re: [chris] CHECKBOXES NOT WORKING!

Chris...

Attached is the code you requested. Since the page appears blank online, I copied the code to Notepad and saved it as a txt document. If there is anyway you can get back to me soon... today... it would be great... I holding up a number of ski pages till I can resolve this.

Best,

Bob T.

Re: [chris] CHECKBOXES NOT WORKING!

Chris...

IT MORE THAN HELPED... IT WORKED!!!!

I can't thank you enough.

Is there anyway I can email YOU direct if...no,no,no.. I ever have another major problem. You saved me from a padded room. Apparently I can't reach you via support@interactivetools.comI

Best,

Bob