Python and HTML hidden input variables

Michael Hudson mwh21 at cam.ac.uk
Fri Oct 22 09:49:07 EDT 1999


rainer2207 at my-deja.com writes:

> I have a Python script which displays a form and has a hidden input. The
> relevant code part looks something like this:
> 
> print "<form method=\"post\" action=\"sendmsg.cgi\">"
> print "<textarea name=\"sndmsg\" rows=\"7\" cols=\"73\" nowrap>"
> print "</textarea>"
> print "<input type=\"HIDDEN\" name=\"username\"  value="test">"
> print "<br>"
> print "<input type=\"submit\" value=\"Talk\">"
> print "</form>"
> 
> I was wondering how I could pass a variable using the hidden field. That
> is I'd like to do something like this:
> 
> test = "Hello"
> print "<input type=\"HIDDEN\" name=\"username\"  value=test>"

I know nothing about CGI, but try:

print "<input type=\"HIDDEN\" name=\"username\"  value=\"%s\">"%test

and then maybe go to www.python.org and read the tutorial there?

HTH,
Michael




More information about the Python-list mailing list