Cannot Get Form To Work

Victor Subervi victorsubervi at gmail.com
Thu Jul 23 11:46:16 EDT 2009


Hi:
When the form comes up the first time, there is the default value for num.
When I fill in a number in the form and press send, even though the form
sends to itself (same page name), I would think it would read the number
sent. Here again is the code:

from primeNumbers import primeNumbers

try:
 lang = form.getfirst('lang', 'en')
 browser = form.getfirst('browser', 'all')
 site = form.getfirst('site', 'bridge')
 num = form.getfirst('num','')
except:
 pass

ourFile = string.split(__file__, "/")
p = ourFile[len(ourFile) - 1]
p = p[: - 9]
site = ourFile[4][:-10]
if site != '':
 site = site[:-1]

print "Content-Type: text/html"
print
print """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<head xmlns="http://www.w3.org/1999/xhtml">
</head>
"""
if num != '':
 num = round(float(num))
 roots = primeNumbers(num)
 print roots
if num == '':
 print """
<form action="http://13gems.com/test-Calculators_frame.py" method="post">
<input type="text" name="num" size="20" maxlength="20" value="Enter number
here..." onfocus="this.value=''" />
<input type="image" src="http://13gems.com/images/search.jpg" name="search"
id="search" />
</form>
"""
print '</body></html>\n'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090723/4dde2fb9/attachment.html>


More information about the Python-list mailing list