How to pass a list of 2 values each to dtml
Hia Zopistas, I have a form that prints out links with checkboxes. I want to pass the checked links to a dtml-method. the form looks like <input type="checkbox" name="urllist:list" value=" [url goes here] || [linkname goes here]"><a href ..... [and here goes the link itself </a> this is printed out for every link. Now I want to call a method foo(url, name) how can I split the passed strings in urllist into 2 parts and assign them to variables in dtml I can pass to foo ? or is there a way to pass a tuple or list in the form directly? TIA Philipp Dunkel
Now I want to call a method foo(url, name) how can I split the passed strings in urllist into 2 parts and assign them to variables in dtml I can pass to foo ? or is there a way to pass a tuple or list in the form directly?
The beauty of a ":list" flag in the value attribute is that Zope will return a Python list. So all you got to say is (untested): <dtml-with urllist> <dtml-let url=sequence-item> <dtml-call foo> </dtml-let> </dtml-with> In foo you can then refer to url. Another way (but more work) would be: <dtml-let url1=urllist[0] url2=urllist[1]> <dtml-call foo> </dtml-let> or <dtml-call "REQUEST('url1', urllist[0])"> <dtml-call "REQUEST('url2', urllist[1])"> But notice that I assume in the last 2 examples that the list has two elements. You would have to write some if statements tomake it work right, so it wont bail on you, in case you have 1 or no url passed. Regards, Stephan -- Stephan Richter - (901) 573-3308 - srichter@cbu.edu CBU - Physics & Chemistry; Framework Web - Web Design & Development PGP Key: 735E C61E 5C64 F430 4F9C 798E DCA2 07E3 E42B 5391
participants (2)
-
Philipp Dunkel -
Stephan Richter