Multiple Selection with "Checkboxes":
Here is a my complete example with integers and strings, just drop it to a DTML method an test it. Best regards Arno <dtml-var standard_html_header> <dtml-call "REQUEST.set('selectedITEMS',['a','b','c'])"> <dtml-in selectedITEMS> <dtml-var "_['sequence-item']"> </dtml-in> <dtml-call "REQUEST.set('List_available_items',['a','b','c'])"> <dtml-in selectedITEMS> <dtml-var "_['sequence-item']"> </dtml-in> <p> <dtml-call "REQUEST.set('List_selected_items',['a','b'])"> <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> <hr> <dtml-call "REQUEST.set('selectedITEMS',[1,2,3])"> <dtml-in selectedITEMS> <dtml-var "_['sequence-item']"> </dtml-in> <dtml-call "REQUEST.set('List_available_items',[1,2,3])"> <dtml-in selectedITEMS> <dtml-var "_['sequence-item']"> </dtml-in> <p> <dtml-call "REQUEST.set('List_selected_items',[1,2])"> <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> <dtml-var standard_html_footer>
On Wed, 25 Jul 2001, you wrote: > Do you think it is because the value are stored in that type: [value1,value2,...] values are integers ?
Regards
Richard
-----Ursprüngliche Nachricht----- Von: Arno Gross [mailto:zope@consotec.de] Gesendet: Mittwoch, 25. Juli 2001 13:59 An: rbendit@netbooster.de; Richard Bendit; dieter@handshake.de; toneman@phil.uu.nl; zope-dev@zope.org; zope@zope.org Betreff: Re: [Zope] Multiple Selection with "Checkboxes":
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 )
-- GMXler aufgepasst - jetzt viele 1&1 New WebHosting Pakete ohne Einrichtungsgebuehr + 1 Monat Grundgebuehrbefreiung! http://puretec.de/index.html?ac=OM.PU.PU003K00717T0492a
participants (1)
-
richard.bendit@gmx.net