Checkboxs for URLs

6 posts by 2 authors in: Forums > CMS Builder
Last Post: January 21, 2009   (RSS)

By Mohaukla - January 20, 2009

I have a multiple listing used for a "Quick Links" area.
I have 2 check boxes for each listing ... one to open in a different window and one to change the link to a CSS style for the text.
i need an IF/ELSE statement for each link that will allow those check box items to be applied.

Current Code
<td height="20"><a href="<?php echo $quicklinksRecord['url'] ?>" class="style4"><?php echo $quicklinksRecord['title'] ?></a></td>

I need a target="_blank" for the checkbox status "1" for the field named 'new_window'

I need class="style4blue" for the checkbox status "1" for the field named 'blue_link'

Could you provide me with the proper IF/ELSE statements for this?

Thanks,
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

Re: [justritedesign] Checkboxs for URLs

By Dave - January 20, 2009

Hi Michael,

Try this:

<?php if ($quicklinksRecord['new_window']): ?>target="_blank"<?php endif ?>

<?php if ($quicklinksRecord['blue_link']): ?>class="style4blue"<?php endif ?>

Just put those where you want them to appear.

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

Re: [justritedesign] Checkboxs for URLs

By Dave - January 20, 2009

Try this:

<?php if ($quicklinksRecord['blue_link']): ?>
class="style4blue"
<?php else: ?>
class="style4"
<?php endif ?>
Dave Edis - Senior Developer
interactivetools.com

Re: [justritedesign] Checkboxs for URLs

By Mohaukla - January 20, 2009

Dave ,
I forgot to mention that the html used in that fashion with the two classes beside each other DOES work. It just seems a patch type fix rather than substituting one class for the other.

For everyone this code does work as long as you put the regular class first and add the checkbox code in front of it:

<td height="20"><a href="<?php echo $quicklinksRecord['url'] ?>" <?php if ($quicklinksRecord['blue_link']): ?>class="style4blue"<?php endif ?>class="style4"<?php if ($quicklinksRecord['new_window']): ?>target="_blank"<?php endif ?>><?php echo $quicklinksRecord['title'] ?></a></td>

Browsers should use whichever class is first. I was just looking for and ELSE statement that would
get me a cleaner result.

Thanks for your help Dave,
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

Re: [justritedesign] Checkboxs for URLs

By Mohaukla - January 21, 2009

Thanks Dave,

That is exactly what I was looking for.

Since this was inside a link I was forced to remove all the whitespace in the code.
But that code does perfectly.

Thanks again,
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"