CGI getting multiple values with same name into a list

Lee Joramo ljoramo.list at nickads.com
Mon May 8 16:33:34 EDT 2000


I am trying to process a web form but can not figure out the proper way to
get mulitple values with the same name into a list. However, instead of
getting a nice list, I get garbled MiniFieldStorage results For example, I
have an html checkbox set with the name "select":

--html web form snippet --
	<form method=GET action='cgi-bin/sort.py'>
	<input type=hidden name="formname" value="form1">
	<input type=checkbox checked name='select' value='type'> type
	<input type=checkbox checked name='select' value='year'> year
	<input type=checkbox checked name='select' value='price'> price
	<input type=checkbox  name='select' value='description'> description
	<input type=checkbox  name='select' value='template'> template
	</form>

----

When the form is submited it passes these values to a python script:

	http://domain.dom/cgi-bin/sample.py?formname=form1&select=type&select=year&
select=price

--sample.py---

#!/usr/bin/python

import cgi
form = cgi.FieldStorage()

print "Content-Type: text/html\n\n"
print "<pre>"

formname = form['formname'].value
print "formname : %s" % formname
try :
	select = form['select'].value
	print "TRY select : %s" % select
except :
	select = form['select']
	print "EXCEPT select: %s" % select

--output of sample.py--

formname : form1
EXCEPT select: [MiniFieldStorage('select', 'type'),
MiniFieldStorage('select', 'year'), MiniFieldStorage('select', 'price')]

---

Of course, what I am looking for is something like:

select == ['type', 'year', 'price']

Thanks for any help.

--
Lee A. Joramo                      ljoramo at nickads.com
The Nickel Want Ads                www.nickads.com
Internet Manager                   970-242-5555

--

Onward and Upward!

Lee A. Joramo }}-----> Cowboy on the Electronic Frontier

lee at joramo.com

Alamar Ranch  -  Palisade  -  Colorado

ThreeRivers|Eagle|UCD|D&D|TNC|DX|Mac|221B|Cannondale|Deutsch





More information about the Python-list mailing list