cgi getlist() problem (my first python program)

Gobo Borz goboborz at yahoo.com
Fri Jun 20 10:53:25 EDT 2003


Max M wrote:
> 
> A simple way is to render the indexes of every item as a hidden field:
> 
> <form>
>   <td>
>     <input type="hidden" name="indexes" value="1">
>     <input name="name1">
>     <input name="phone1">
>   </td>
>   <td>
>     <input type="hidden" name="indexes" value="2">
>     <input name="name2">
>     <input name="phone2">
>   </td>
> </form>
> 
> 
> results = []
> for idx in cgi['indexes'].value:
>     name = cgi.get('name%s' % idx, '')
>     phone = cgi.get('phone%s' % idx, '')
> results.append((name, phone))
> 


This seems like an elegant way to do it. This way, you wouldn't have to have
a ROW_COUNT "pseudo-constant" in your program that would have to be changed
if the number of rows changed.

Thanks!  --Greg





More information about the Python-list mailing list