Multi table search

6 posts by 5 authors in: Forums > CMS Builder
Last Post: August 3, 2010   (RSS)

Re: [willydoit] Multi table search

By gkornbluth - May 11, 2010 - edited: May 11, 2010

Hi willydoit,

The answer to the first question should be fairly easy.

here's an excerpt from my CMSB Cookbook http://www.thecmsbcookbook.com that describes an approach:

RENDERING PHP CODE ON ".HTML" FILES
This method outlines how you can use PHP code on files created with the ".html" extension.

Create a plain text file called ".htaccess", and add the following line to it:

Addhandler application/x-httpd-php .html .php

Now upload this file to the root web directory on your server. You should now be able to use CMS Builder's code on any page with the ".html" or ".php" extensions. You can even add your own custom extensions to the code above if you'd like, such as ".shtml" or ".htm". This method is ideal for situations where you need to use CMS Builder on a site that currently uses static HTML pages, but would like to preserve the site's existing URL's.


Hope this helps.

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] Multi table search

By willydoit - May 11, 2010

Thanks Jerry,

I will make a start with that.

Re: [willydoit] Multi table search

By Kenny - May 11, 2010 - edited: May 11, 2010

For the drop down list, try a bit of javascript with it:

<form name="form">

<select name="select" onChange="displaydesc(document.form.select, thetext, 'textcontainer')">
<option selected="" value="">Accommodation Type</option>
<?php foreach ($accommodationsRecords as $record): ?>
<option value="<?php echo $record['_link'] ?>"><?php echo $record['accommodation'] ?></option>
<?php endforeach; ?>
</select>

<input onClick="jumptolink(document.form.select)" type="button" value="Go" />

</form>

<script type="text/javascript">

function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}
</script>



Kenny

Re: Search box - CMS builder

Hi

I've been looking through the forum for a drop down search box, and this solution posted sort of meets my needs, but I was wondering if there's a way to be a bit more "clever". The code you provided is:

<form name="form">

<select name="select" onChange="displaydesc(document.form.select, thetext, 'textcontainer')">
<option selected="" value="">Accommodation Type</option>
<?php foreach ($accommodationsRecords as $record): ?>
<option value="<?php echo $record['_link'] ?>"><?php echo $record['accommodation'] ?></option>
<?php endforeach; ?>
</select>

<input onClick="jumptolink(document.form.select)" type="button" value="Go" />

</form>

<script type="text/javascript">

function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}

function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}
</script>


However, I wanted to be able to show the search box without the "Go" button, and be able to add a suburb listing within which to group the properties - for example, http://www.fordland.com.au/ (see top right hand corner search). This search box is for the old website and I'm moving it over to a CMS builder. Is this possible? Any suggestions.



thanks

Re: [degreesnorth] Search box - CMS builder

By Jason - August 3, 2010

Hi,

From the sounds of it you want to be able to do 2 things. First, be able to group drop down options. There is a tag called <optgroup> that will allow you to do that. See here for more information on how that tag works:
http://www.w3schools.com/TAGS/tag_optgroup.asp

As for the second issue, it sounds like you want to have the list box execute the same code that the submit button does when its value changes. You can do this by calling the same event that the submit button does. Try changing the code like this:

<select name="select" onChange="displaydesc(document.form.select, thetext, 'textcontainer'); jumptolink(document.form.select);">

Hopefully this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/