Hidden CGI fields in HTML

Paul Boddie paulb at infercor.no
Tue Aug 10 06:57:15 EDT 1999


Ian Clarke wrote:
> 
> Hi,
> 
> I am using CGI with Python and am trying to find a way that I can
> generate the HTML for a form such that one of the INPUT controls will
> have a fixed value (set when the page is generated by a previous CGI
> script), that CANNOT be edited by the user (or prefereably not even
> seen) - but will be passed to the next CGI script.

Ah, the classic state-being-held-in-the-form style of CGI programming.

> I am aware that there are "readonly" and "disabled" tags for INPUT
> controls defined in the HTML 4 spec, and even a style="display:none"
> attribute should work in theory, but none of these seem to work with
> Netscape.  The readonly and disabled tags have no obvious effect, and
> while setting the style to "display:none" does stop it being displayed,
> it also stops the parameter being passed in the form!
> 
> Has anyone actually achieved this seemingly simple task?

Indeed. Use:

<input name=fieldname value=defaultvalue type=hidden>

That should do the trick, if you replace "defaultvalue" with the fixed value you
mentioned above. It is important to be sure that in applications where such
state variables could contain sensitive information or validated information, it
may not be desirable to store the state of a "dialogue" in the page.

Anyway, see http://www.w3.org/TR/REC-html32.html#fields for more information on
what the INPUT element can do.

Paul




More information about the Python-list mailing list