Skip to content

Instantly share code, notes, and snippets.

@alanfluff
Forked from outflux3/search-form.php
Created June 7, 2013 11:50
Show Gist options
  • Save alanfluff/5728731 to your computer and use it in GitHub Desktop.
Save alanfluff/5728731 to your computer and use it in GitHub Desktop.
<form name='search' id='product-search' method='get' action='<?php echo $config->urls->root?>speaker-finder/'>
<ul id="row1">
<li>
<label for='search_app'>Application</label>
<select id='search_app' name='application' onchange="$(this.form).trigger('submit')">
<option value=''>Any</option><?php
// generate the application options, checking the whitelist to see if any are already selected
foreach($pages->get(1016)->children('include=all') as $app) {
$selected = $app->name == $input->whitelist->application ? " selected='selected' " : '';
$selected = $app->name == $input->get->application ? " selected='selected' " : '';
echo "<option$selected value='{$app->name}'>{$app->title}</option>";
}
?>
</select>
</li>
<li>
<label for='search_use'>Product Type</label>
<select id='search_use' name='product_use' onchange="$(this.form).trigger('submit')">
<option value=''>Any</option><?php
// generate the use options, checking the whitelist to see if any are already selected
foreach($pages->get("/speakers/")->children() as $use) {
$selected = $use->name == $input->whitelist->product_use ? " selected='selected' " : '';
$selected = $use->name == $input->get->product_use ? " selected='selected' " : '';
echo "<option$selected value='{$use->name}'>{$use->title}</option>";
}
?>
</select>
</li>
<li>
<label for='search_series'>Product Series</label>
<select id='search_series' name='series' onchange="$(this.form).trigger('submit')">
<option value=''>Any</option><?php
// generate the list of product series, checking our whitelist to see if any are already selected
foreach(array('MicroWalsh', '1000', '2000', '3000', '4000', '5000') as $series) {
$selected = $series == $input->whitelist->series ? " selected='selected'" : '';
$selected = $series == $input->get->series ? " selected='selected'" : '';
echo "<option$selected value='$series'>$series</option>";
}
?>
</select>
</li>
<li>
<label for='search_distance'>Distance (ft)<span class='tip' title='Enter the maximum distance you will sit from the speakers'><icon class='icon-info-sign'></icon></span></label>
<input type='number' name='distance' id='search_distance' value='<?php
if($input->whitelist->distance) echo $sanitizer->entities($input->whitelist->distance);
if($input->get->distance) echo ($input->get->distance); ?>' />
</li>
</ul>
<ul id="row2">
<li>
<label for='search_length'>Room Length (ft)<span class='tip' title='To return size based results, enter length, width and height'><icon class='icon-info-sign'></icon></span></label>
<input type='number' name='length' id='search_length' value='<?php
if($input->whitelist->length) echo $sanitizer->entities($input->whitelist->length);
if($input->get->length) echo ($input->get->length); ?>' />
</li>
<li>
<label for='search_width'>Room Width (ft)<span class='tip' title='To return size based results, enter length, width and height'><icon class='icon-info-sign'></icon></span></label>
<input type='number' name='width' id='search_width' value='<?php
if($input->whitelist->width) echo $sanitizer->entities($input->whitelist->width);
if($input->get->width) echo ($input->get->width); ?>' />
</li>
<li>
<label for='search_height'>Room Height (ft)<span class='tip' title='Average room heights are 9-10 ft.'><icon class='icon-info-sign'></icon></span></label>
<input type='number' name='height' id='search_height' value='<?php
if($input->whitelist->height) echo $sanitizer->entities($input->whitelist->height);
if($input->get->height) echo ($input->get->height); ?>' />
</li>
<li>
<label for='search_price'>Max Price ($USD)<span class='tip' title='Enter max price for single speaker'><icon class='icon-info-sign'></icon></span></label>
<input type='number' name='price' id='search_price' value='<?php
if($input->whitelist->price) echo $sanitizer->entities($input->whitelist->price);
if($input->get->price) echo ($input->get->price); ?>' />
</li>
</ul>
<ul id="row3">
<li>
<input type='text' name='name' id='search_name' placeholder='Product Name (optional)' value='<?php
if($input->whitelist->name) echo $sanitizer->entities($input->whitelist->name);
if($input->get->name) echo ($input->get->name); ?>' />
</li>
</ul>
<ul id="row4">
<li><button class ='btn btn-success' type='submit' id='search_submit' name='submit1' value='Search'>Search <icon class='icon-search'></icon></button></li>
</ul>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment