[Zope-DB] Question involving passing optional parameters to a
aaron at hypervision.com
Tue Oct 19 12:25:03 EDT 2004
This is very easy in my experience, just use dtml-sqlgroup.
If you're using mysql, make your checkbox fields enums. ex:
golf enum('Y','N') default NULL,
tennis enum('Y','N') default NULL,
swim enum('Y','N') default NULL,
Your html looks like:
<INPUT TYPE="checkbox" NAME="golf" value="Y">Golf Course<BR>
<INPUT TYPE="checkbox" NAME="tennis" value="Y">Tennis Court<BR>
<INPUT TYPE="checkbox" NAME="swim" value="Y">Swimming Pool<BR>
And the method looks like:
Select somefields from db
...some match (required) ...
<dtml-sqltest golf type="nb" op=eq optional>
<dtml-sqltest tennis type="nb" op=eq optional>
<dtml-sqltest swim type="nb" op=eq optional>
Make sure the initial query entry is always entered, otherwise you may
get an error if the user doesn't select anything.
Laura McCord wrote:
>I have a form with 7 checkboxes. The more checkboxes are selected the
>more narrow of results you will get. I created a zsql method that will
>handle every case as far as when to include 'AND','OR', and '()'.
>The problem now is getting my form to execute the zsql method correctly.
>When I hit the submit button the boxes that are not check will trigger
>an error message stating that the variable was not defined.
>I am trying to figure out when I hit the submit button my dtml method
>that runs the zsql method is not written to adjust for empty parameters.
>I had originally called my function like this:
> <dtml-call expr="findResults(location1=location1, location2=location2,
>..., usetype1=usetype1, usetype2=usetype2,...,active=active)">
>Does anyone have an idea on how to call this function regardless of what
>boxes are checked?
>Zope-DB mailing list
>Zope-DB at zope.org
More information about the Zope-DB