Output html list : Introduction : CGI Web PYTHON TUTORIALS


PYTHON TUTORIALS » CGI Web » Introduction »

 

Output html list


#!/usr/bin/env python

import cgitb
cgitb.enable()

import cgi, os, urllib

print "Content-type: text/html"
print

print """<HTML>
<HEAD>
<TITLE>CGI List Example</TITLE></HEAD><BODY>"""

form = cgi.FieldStorage()
print "You selected: "
selections = form.getlist('data')
printable = [cgi.escape(xfor x in selections]
print ", ".join(printable)


print """<FORM METHOD="GET" ACTION="%s">
Select some things:<P>""" % os.environ['SCRIPT_NAME']
for item in ['A''B''C''D''E''F','G']:
    print '<INPUT TYPE="checkbox" NAME="data" VALUE="%s">' % cgi.escape(item)
    print ' %s<BR>' % cgi.escape(item)
print """<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>
</BODY></HTML>"""



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo CGI Web
» Introduction