jump Menu from checkboxes

7 posts by 3 authors in: Forums > CMS Builder
Last Post: October 23, 2010   (RSS)

Businesses are listed in a multi-section editor and separated by categories with checkboxes since a single business can have multiple categories. I'm trying to create a jump menu that shows all listings under specific checked-off categories and was able to do it with the below code... only problem is, any listing that is double-exposed, shows up twice... can we avoid the duplication?
<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
<option value="#" selected="selected">Find a Store</option>
<?php foreach ($local_listingsRecords as $record): ?>
<?php if (strpos($record['subsection'], 'Animals/Pets')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-animalsPets.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Antiques')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-antiques.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Apparel and Accessories')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-apparelAccessories.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Crafts and Gifts')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-craftsGifts.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Furniture')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-furniture.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Galleries')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-galleries.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Home/Decor')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-homeDecor.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php if (strpos($record['subsection'], 'Jewelry')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-jewelry.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php endforeach ?>
</select>

John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] jump Menu from checkboxes

By Chris - October 20, 2010 - edited: October 22, 2010

Hi jtedescojam,

You can use elseif to prevent more than one of your conditional blocks from running:

<select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
<option value="#" selected="selected">Find a Store</option>
<?php foreach ($local_listingsRecords as $record): ?>
<?php if (strpos($record['subsection'], 'Animals/Pets')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-animalsPets.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Antiques')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-antiques.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Apparel and Accessories')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-apparelAccessories.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Crafts and Gifts')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-craftsGifts.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Furniture')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-furniture.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Galleries')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-galleries.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Home/Decor')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-homeDecor.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php elseif (strpos($record['subsection'], 'Jewelry')): ?>
<option value="http://ilovechester.accountsupport.com/shopping-jewelry.php#<?php echo urlencode($record['title']) ?>"><?php echo $record['title'] ?></option>
<?php endif ?>
<?php endforeach ?>
</select>


Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] jump Menu from checkboxes

I see what you did here... but I'm getting an internal server error 0 with this markup
John Tedesco

Creative Director



JAM Graphics

Re: [zick] jump Menu from checkboxes

Thank you Zick for pointing this out.. I tried to go through this and understand the difference.. but it's just a little too confusing since I think the setup was a little different... Chris, can you see where the error is coming from in what you sent?
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] jump Menu from checkboxes

By Chris - October 22, 2010

Hi jtedescojam,

Oops. I wrote "else if" before, but I should have said "elseif" (with no space.) I've fixed my post above to be correct. Can you try making those changes and see if that fixes things?
All the best,
Chris

Re: [chris] jump Menu from checkboxes

Thanks Chris, I really didn't think that could have been a possibility! [:P]
John Tedesco

Creative Director



JAM Graphics