Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Custom Search Form for ListViewer

 

 


Dawna
Novice

Feb 27, 2008, 3:51 PM

Post #1 of 3 (349 views)
Shortcut
Custom Search Form for ListViewer Can't Post

I am using a code similar to this on one of my ListViewer pages and it works great but we will need to provide the pre-defined list of catogories to run the search. Can you provide the code that allows me to include a pre-defined drop down box for the search? Wink

<form method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Categories: <input type="text" name="category" value="" size="15">
<input type="submit" name="" value="Search">
</form>



Dave
Staff / Moderator


Feb 27, 2008, 5:42 PM

Post #2 of 3 (346 views)
Shortcut
Re: [Dawna] Custom Search Form for ListViewer [In reply to] Can't Post

Sure, there's no automatic way to do that but it's possible with some PHP code. Try this:


Code
<select name="category"> 
<?php
$tablename = $options['tableName'];
$fieldname = 'yourFieldName';
$schema = loadSchema($tablename);
$fieldSchema = $schema[$fieldname];
$fieldOptions = getListOptionsFromSchema($fieldSchema);

foreach ($fieldOptions as $valueAndLabel) {
list($value, $label) = $valueAndLabel;
$encodedValue = htmlspecialchars($value);
$encodedLabel = htmlspecialchars($label);
print "<option value='$encodedValue'>$encodedLabel</option>\n";
}
?>
</select>


Just page that where you want your dropdown list and change the fieldname to match yours and it should work.

For more details, have a look at this thread:
http://www.interactivetools.com/iforum/P59787

Let me know if you have any trouble with that.

Dave Edis - Senior Developer
interactivetools.com


Dawna
Novice

Feb 27, 2008, 7:49 PM

Post #3 of 3 (345 views)
Shortcut
Re: [Dave] Custom Search Form for ListViewer [In reply to] Can't Post

Rock 'n Roll! You're awesome.

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4