【发布时间】:2011-09-20 04:53:54
【问题描述】:
我用Python写了一个网页如下:
#!/usr/bin/env python
import os, re, sys
from datetime import datetime
from pymongo import Connection
import cgi
class Handler:
def do(self, environ, start_response):
html = "<html><head><title>C Informatics</title></head><body>"
html += "<h1><center>National Management & Information System</h1>"
html += '<center><h3>CONTROL PROGRAMME<br>'
html += '</center>'
html += '<form method="post" action="newreg.py">'
html += 'Person Name :<input type="text" name="pname">'
html += 'Age :<input type="text" name="age">'
html += 'Gender : <input type="radio" name="sex" value="male">M'
html += '<input type="radio" name="sex" value="female">F<br><br>'
html += 'Complete Address :<br>'
html += 'H.No. and Street :<input type="text" name="hn1">'
html += 'Locality : <input type="text" name="locality">'
html += 'PIN Code : <input type="text" name="pin"><br>'
html += '<input type="submit" Value="Save">'
html += '</form>'
html += '</center>'
html += "</body></html>"
connection = Connection('localhost', 27017)
db = connection.health
tc = db.testColl
item = tc.find_one()["name"]
html += str(item)
html += name
output = html
mimeType = "text/html"
在上面的表单中,我想自动填写表单字段“位置”(它还会提取该位置的相应 PIN 码并显示在字段 PIN 中)。
数据、位置名称及其各自的 PIN 码保存在 MongoDB 的集合中。
这样当点击“保存”时,信息就会保存在 MongoDB 的新集合中。
有代码,有人可以告诉我怎么做吗?
谢谢
NC
【问题讨论】:
标签: python forms autocomplete