CGI question on input type=text form elements

DeepBlue DeepBlue at DeepBlue.org
Thu Oct 11 21:48:47 CEST 2001


Rhett
I discovered that this is happening when the form is enclosed in a table.
For example:
<table>
<form action="poster.cgi" method="post">
<tr>
<td><input type="text" name="text_1">
<td><input type="submit" name="submit" value="Submit">
<tr><input type="reset" name="reset" value="Reset">
</form>
<form>

Why a form in a table?  Actually, I have four forms on rhe web page and I
need to arrange them in a certain way.  Anyway, when the form is in a table
I am getting the text_1 key.  No table, no key.
If you have the time, try it and let me know if you are getting the same
thing.  I am using IPlanet on Solaris with Python 2.1
Thanks
DB
"Rhett" <lookuprhett at yahoo.com> wrote in message
news:3acd06c8.0110111028.7e057da0 at posting.google.com...
> You must have made a silly mistake somewhere. Either that or there is
> a browser/web server issue. This works fine for me on apache under
> linux, python 2.1.1
>
> [index.html]
> <html>
> <form action='poster.cgi'>
> <input name='test_1' type='text'>
> <input name='submit' value='submit' type='submit'>
> </form>
> </html>
>
> [poster.cgi]
> #!/usr/bin/python
>
> import cgi
>
> form = cgi.FieldStorage()
>
> print 'Content-type:text/html\n\n'
> for f in form.keys():
>     print str(f) + ': ' + str(form[f].value)
>
>
>
> "DeepBlue" <DeepBlue at DeepBlue.org> wrote in message
news:<tsb9cb92pql297 at corp.supernews.com>...
> > I am running into a strange problem with a form while using CGI module
in
> > Python.
> > Let us say I have the following form:
> > <form>
> > <input type="text" name="text_1">
> > <input type="submit" name="submit" value="test">
> > </form>
> >
> > Now, let us say that test_form=cgi.FieldStorage()
> > If the above form is submitted without typing anything in the text field
one
> > expects test_form.keys() to generate:
> > ['submit']
> >
> > But i am getting:
> > ['text_1', 'submit']
> > Which is unexpected, and in my case, undesirable.  What am I doing
wrong?
> > DB





More information about the Python-list mailing list