469,609 Members | 1,455 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

CGI module: get form name

ej

I'm not seeing how to get at the 'name' attribute of an HTML <form> element.

form = cgi.FieldStorage()

gives you a dictionary-like object that has keys for the various named
elements *within* the form...

I could easily replicate the form name in a hidden field, but there ought to
be some way to get directly at the form name but I'm just not seeing it. I
looked in the os.environ() - don't see it there.

Any ideas?

Thanks! :)

--------------------------------------------------------------
"I strongly believe what we're doing is the right thing. If I didn't believe
it-I'm going to repeat what I said before-I'd pull the troops out, nor if I
believed we could win, I would pull the troops out." --President George W.
Bush, Charlotte, N.C., April 6, 2006
Apr 13 '06 #1
2 1645
ej wrote:
I'm not seeing how to get at the 'name' attribute of an HTML <form> element.

form = cgi.FieldStorage()

gives you a dictionary-like object that has keys for the various named
elements *within* the form...

I could easily replicate the form name in a hidden field, but there ought to
be some way to get directly at the form name but I'm just not seeing it.


There isn't. This is a limitation of the CGI protocol, due to the way
HTTP requests work. I.e., the name attribute of <form> is *not*
included in form submissions. Regardless of whether the method is GET
or POST, it's only the fields' key/value pairs that are encoded and
sent off to the server.

If you need it, a hidden field is a good place for the form name. Or
you could use cookies.

Hope that helps,
--Ben

Apr 13 '06 #2
"ej" <ejohnso9 at @earthlink.dot.net> wrote:

I'm not seeing how to get at the 'name' attribute of an HTML <form> element.

form = cgi.FieldStorage()

gives you a dictionary-like object that has keys for the various named
elements *within* the form...

I could easily replicate the form name in a hidden field, but there ought to
be some way to get directly at the form name but I'm just not seeing it. I
looked in the os.environ() - don't see it there.


Nope, the form name is not transmitted as part of the HTTP request. It
only exists for the convenience of the client-side code (like Javascript).
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Apr 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.