Jason, Very cool, thanks!
--jim -----Original Message----- From: Jason Hildebrand [mailto:[EMAIL PROTECTED]] Sent: Thursday, February 21, 2002 6:58 PM To: Jim Kraai Cc: '[EMAIL PROTECTED]' Subject: Re: [Webware-discuss] Leaving PHP--WebWare CGI form variables question On Thu, 2002-02-21 at 20:45, Jim Kraai wrote: > what are valid names for form variables > > in PHP I could use the following in the name attribute of an input elt: > name result > ----------- ------------- > "asdf" normal > "asdf[]" creates array w/ name asdf and appends submitted value to > that array > "asdf[jkl]" creates array w/ name asdf and assigns asdf['jkl'] = > submitted value > Which of these (aside from the obvious first one) can I use in Python with > the various cgi'ish things included in WebWare? Webware will notice if there is more than one value for a specific key, and will create a list for you. For example, I have a list of items in a form, and each item has a checkbox next to it: (I've simplified this code for the purpose of the example) for i in mylist: self.writeln( i['name'] ) self.writeln('<input type="checkbox" value="%s" name="checked">' % i['id'] ) So my form contains many "inputs" which have the name "checked". So the user may select one or more items by checking the boxes. In my action handler "delete", I need to check which items should be deleted from the list. checked = self.request().value('checked') if type(checked) is not ListType: checked = [ checked ] mylist = [ item for item in mylist if item['id'] not in checked ] > Do they all (mod_python, one shot, cgiwrapper, etc?) behave the same? Yes, they should. > Are there other constructs available to get vars into arrays? I don't know... maybe others can answer this question. -- Jason D. Hildebrand [EMAIL PROTECTED] _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
