hidden fields in HTML forms

Gary Herron gherron at aw.sgi.com
Mon Aug 2 17:04:46 EDT 1999

Rick Robino wrote:
> Greetings,
> Could anyone point me in the right direction of finding a cgi class
> that catches hidden fields sent to it from an HTML form? cgi.py doesn't
> recognize them; HTMLgen does define an input class which includes
> hidden fields which it can create but that won't help much in parsing
> already created form output except for deriving my own class.

Not true.  The cgi module recognizes and makes available all parameters
which come back from the form, and hidden values are sent back from the
form like any other parameter.

If a form has a field like this:
	<INPUT TYPE=hidden NAME=user VALUE=xxx>	

then when your python script is invoked, you can get at the value like

	query = cgi.parse()
	if query.has_key('user'):
		user = query['user'][0] #First and only element on the list
		user = None # or whatever ...

Dr. Gary Herron <gherron at aw.sgi.com>
Alias | Wavefront
1218 3rd Ave, Suite 800, Seattle WA 98101

More information about the Python-list mailing list