Hi, I have a form which has (dynamically-generated) checkboxes (from database rows). these are of the form: <input type=checkbox name="ismember:list:string" checked><dtml-var sequence-var-name> (some do not default to checked). When I'm processing the form data, the list contains data for only those that are checked (i.e. no list if none are checked, a short list if some are checked). How can I generate a list of boolean values representing the user's selections? I need to use the boolean value in a dtml-if in the sql that processes the form data. Any help would be greatly appreciated, thanks, Rua HM. http://mobile.yahoo.com.au - Yahoo! Mobile - Check & compose your email via SMS on your Telstra or Vodafone mobile.
I have a form which has (dynamically-generated) checkboxes (from database rows).
these are of the form: <input type=checkbox name="ismember:list:string" checked><dtml-var sequence-var-name> (some do not default to checked).
When I'm processing the form data, the list contains data for only those that are checked (i.e. no list if none are checked, a short list if some are checked).
That's a tricky issue with web programming in general: a form will only report a value for a check box when it is checked, and otherwise will ignore it. There are two common ways out: 1) drop the checkbox and use radio buttons (or perhaps some other widget), which will guarantee a return value. 1b) add a hidden field for each question, and count an affirmative only when you get the hidden field and the interactive checkbox's value. 2) somehow know server-side what your questions would have been and compare the returned "affirmative" responses. Number 2 is more work, but better with regards to security (you can't trust users to exclusively use your form) and allows you to keep your existing aesthetic (as opposed to #1). I suppose there's also some monkey business you could do with JavaScript, but I don't really care enough to check on that. --jcc
Rua Haszard Morris wrote at 2003-3-10 13:04 +1300:
I have a form which has (dynamically-generated) checkboxes (from database rows).
these are of the form: <input type=checkbox name="ismember:list:string" checked><dtml-var sequence-var-name> (some do not default to checked).
When I'm processing the form data, the list contains data for only those that are checked (i.e. no list if none are checked, a short list if some are checked).
How can I generate a list of boolean values representing the user's selections? I need to use the boolean value in a dtml-if in the sql that processes the form data.
Say: "allCheckboxValues" is the sequence of checkbox values (they must have different values such that you are able to distinguish the checkboxes). You build the sequence of booleans in "isCheckboxSelectedList". The code looks somehow like: isCheckboxSelectedList= [] for checkboxValue in allCheckboxValues: isCheckboxSelectedList.append(checkboxValue in ismember) Dieter
Hi, I have a form which dynamically allows different SQL queries to be specified based on the contents of a subfolder (i.e. each SQL method in the subfolder becomes a checkbox). e.g. <dtml-in "sqlFolder.objectValues()"> <input type=checkbox name=generateemails:list:string value=<dtml-var sequence-var-id>><dtml-var sequence-var-title></input> </dtml-in> When the form is submitted, the methods are stored in a list of strings. How can I call (dtml-in style) the SQL methods specified by the string? e.g. (this is wrong obviously, but is there a way to do it?) <dtml-in generateemails> //the list of queries returned <dtml-in sequence-item>//the current query??? <dtml-var sequence-item> </dtml-in> </dtml-in> Any help would be greatly appreciated, as would replies directly to ruahm@yahoo.com. Thanks, Rua HM. ===== Rua Haszard Morris Software Engineer & Research Assistant MARCS Auditory Laboratories http://apps.uws.edu.au/marcs http://mobile.yahoo.com.au - Yahoo! Mobile - Check & compose your email via SMS on your Telstra or Vodafone mobile.
I realise with the below that I should probably use a python script. I still have the same question though - how can I call the sql methods by name stored in a string? i.e. the method names are parameters to the script, and it should execute the queries, process and return the query data. Thanks in advance for any help, Rua HM.
original message Hi,
I have a form which dynamically allows different SQL queries to be specified based on the contents of a subfolder (i.e. each SQL method in the subfolder becomes a checkbox). e.g. <dtml-in "sqlFolder.objectValues()"> <input type=checkbox name=generateemails:list:string value=<dtml-var sequence-var-id>><dtml-var sequence-var-title></input> </dtml-in> When the form is submitted, the methods are stored in a list of strings. How can I call (dtml-in style) the SQL methods specified by the string? e.g. (this is wrong obviously, but is there a way to do it?) <dtml-in generateemails> //the list of queries returned <dtml-in sequence-item>//the current query??? <dtml-var sequence-item> </dtml-in> </dtml-in> Any help would be greatly appreciated, as would replies directly to ruahm@yahoo.com. Thanks, Rua HM. ===== Rua Haszard Morris Software Engineer & Research Assistant MARCS Auditory Laboratories http://apps.uws.edu.au/marcs http://mobile.yahoo.com.au - Yahoo! Mobile - Check & compose your email via SMS on your Telstra or Vodafone mobile.
If 'sqlmethodname' is a string containing the name of the ZSQL method you want to use, then this will work: <dtml-in "_[sqlmethodname]"> <dtml-var fieldname> </dtml-in> But it is really horrible! I would try to avoid doing this. A -- Logical Progression Ltd, 16 Forth Street, Edinburgh EH1 3LH, UK Tel: +44 (0)131 466 9585 Web: http://www.logicalprogression.net/ On 20/4/03 1:55 am, "Rua Haszard Morris" <ruahm@yahoo.com> wrote:
I realise with the below that I should probably use a python script. I still have the same question though - how can I call the sql methods by name stored in a string? i.e. the method names are parameters to the script, and it should execute the queries, process and return the query data.
Thanks in advance for any help, Rua HM.
participants (4)
-
Andrew Veitch -
Dieter Maurer -
J Cameron Cooper -
Rua Haszard Morris