On Wed, Mar 27, 2002 at 01:30:23PM -0800, Colin Fox mailed:
Hi, all.
I have a ZSQL insert function that requires an optional parameter.
The variables are coming from an HTML form, and one of the variables is a checkbox. Apparently, if the checkbox is unchecked, the variable doesn't appear.
As a small example, let's say there were two strings and a checkbox, labelled str1, str2 and cb. I need this:
insert into mytable(col1, col2, col3) values (str1, str2, cb)
as well as
insert into mytable(col1, col2) values (str1, str2)
if cb is None.
I can't find any examples of optional insert variables, just optional join parameters.
You could do something like this <dtml-if "REQUEST.has_attr(cb)"> <dtml-call dbInsert(str1 = REQUEST[str1], str2 = REQUEST[str2], cb = REQUEST[cb] )"> <dtml-else> <dtml-call dbInsert(str1 = REQUEST[str1], str2 = REQUEST[str2], cb = '' )"> </dtml-if> -- Bryan C. Andregg Duke University Medical Center Programmer Dept. of Anesthesiology e <bryan.andregg@duke.edu> p +1 919 684 6201