Multiple Selection with "Checkboxes":
What i use is: 1. UpdateForm (DTML-Method) 2. List_available_items (ZSQL-Method) "select ap_id,ap_docname from AliasPages where proj_id=<dtml-sqlvar proj_id type=int>" 3. List_selected_items (ZSQL-Method) "select ap_selection from Projects where proj_id=<dtml-sqlvar proj_id type=int>" Problem: I want that the Checkboxes are "CHECKED" if "available_items" == "selected_items" I am not sure if my dtml is wrong or the sql-method: ! See the TIP at the end of this mail ! **************************** Here the: "UpdateForm" **************************** <dtml-call "REQUEST.set('selectedITEMS',[])"> <dtml-in List_SelectedALIASPAGES> <dtml-call "selectedITEMS.append(proj_id)"> </dtml-in> <dtml-in List_available_items> <input type=checkbox name=ap_selection:list value="<dtml-var sequence-item>" <dtml-call expr="REQUEST.set(selectedAP,_['sequence-item'])"> <dtml-in List_selected_items> <dtml-if expr="_['sequence-item'] == selectedITEMS"> checked </dtml-if>> </dtml-in> <dtml-var sequence-item><br> </dtml-in> </TD> </TR><dtml-comment>colname:ap_selection,table:Projects</dtml-comment> **************************** Here a tip i found: "How to construct such a query? If you know, that your values do not contain quotes (i.e. '), then you can use "_.string.join" like this: select ... where col in ( <dtml-var "_.string.join(multiple_selection,',')"> )" I recognized that a lot of USERS have these problems with "Multiple Selections". So if you will help to find a good way to manage this i will post a "How-To" in Zope and i wanted to create an ADD-ON for the great product "ZNolk". THANX you all for your time. REGARDS Richard
You can try: <dtml-in List_available_items> <input type=checkbox name=ap_selection:list value="<dtml-var "_['sequence-item']">" <dtml-if expr="_['sequence-item'] in List_selected_items"> checked (<dtml-var "_['sequence-item']">) </dtml-if>
<dtml-var sequence-item><br> </dtml-in> You have a list and you must ask for membership (with 'in'), also you can save one <dtml-in>. Best regards Arno
On Wed, 25 Jul 2001, Richard Bendit wrote: What i use is:
1. UpdateForm (DTML-Method) 2. List_available_items (ZSQL-Method) "select ap_id,ap_docname from AliasPages where proj_id=<dtml-sqlvar proj_id type=int>" 3. List_selected_items (ZSQL-Method) "select ap_selection from Projects where proj_id=<dtml-sqlvar proj_id type=int>"
Problem: I want that the Checkboxes are "CHECKED" if "available_items" == "selected_items"
I am not sure if my dtml is wrong or the sql-method: ! See the TIP at the end of this mail !
**************************** Here the: "UpdateForm" ****************************
<dtml-call "REQUEST.set('selectedITEMS',[])"> <dtml-in List_SelectedALIASPAGES> <dtml-call "selectedITEMS.append(proj_id)"> </dtml-in>
<dtml-in List_available_items> <input type=checkbox name=ap_selection:list value="<dtml-var sequence-item>" <dtml-call expr="REQUEST.set(selectedAP,_['sequence-item'])"> <dtml-in List_selected_items> <dtml-if expr="_['sequence-item'] == selectedITEMS"> checked </dtml-if>> </dtml-in> <dtml-var sequence-item><br> </dtml-in> </TD> </TR><dtml-comment>colname:ap_selection,table:Projects</dtml-comment>
****************************
Here a tip i found:
"How to construct such a query? If you know, that your values do not contain quotes (i.e. '), then you can use "_.string.join" like this:
select ... where col in ( <dtml-var "_.string.join(multiple_selection,',')"> )"
I recognized that a lot of USERS have these problems with "Multiple Selections". So if you will help to find a good way to manage this i will post a "How-To" in Zope and i wanted to create an ADD-ON for the great product "ZNolk".
THANX you all for your time.
REGARDS
Richard
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I restricted your address list. You have been a bit generous with the distribution. Richard Bendit writes:
What i use is:
1. UpdateForm (DTML-Method) 2. List_available_items (ZSQL-Method) "select ap_id,ap_docname from AliasPages where proj_id=<dtml-sqlvar proj_id type=int>" 3. List_selected_items (ZSQL-Method) "select ap_selection from Projects where proj_id=<dtml-sqlvar proj_id type=int>"
Problem: I want that the Checkboxes are "CHECKED" if "available_items" == "selected_items"
I am not sure if my dtml is wrong or the sql-method:! .... <dtml-in List_available_items> <input type=checkbox name=ap_selection:list value="<dtml-var sequence-item>" The value specifies what value is send to the server if the checkbox is checked and the containing form submitted. "List_available_items" returns (effectively) a sequence of rows. This means "sequence-item" above is bound to such a row. It is a bad value. It will arrive as something like '<Record instance at XXXX>' at the server. I am sure, you do not want this.
<dtml-call expr="REQUEST.set(selectedAP,_['sequence-item'])"> <dtml-in List_selected_items> <dtml-if expr="_['sequence-item'] == selectedITEMS"> checked </dtml-if>>
Again: "List_selected_items" returns a list of rows. A row is not equal to a list... Dieter
participants (3)
-
Arno Gross -
Dieter Maurer -
Richard Bendit