【发布时间】:2012-10-25 21:31:49
【问题描述】:
我正在尝试在我的 HTML 中使用复选框,将这些复选框返回到我的 python 后端,然后如果单击该框,则增加三个计数器。
现在我的 HTML 如下并且工作正常:
<form method="post">
<input type="checkbox inline" name="adjective" value="entertaining">Entertaining
<input type="checkbox inline" name="adjective" value="informative">Informative
<input type="checkbox inline" name="adjective" value="exceptional">Exceptional
</form>
然后在我的 python 后端我有以下内容:
def post(self):
adjective = self.request.get('adjective ')
if adjective :
#somehow tell if the entertaining box was checked
#increment entertaining counter
#do the same for the others
【问题讨论】:
-
我想也许可以在 html "adjective[]" 中命名...也许...
-
你知道你可以
print adjective看看里面有什么,对吧?它最终会与您的 HTML 混在一起,但您可以查看源代码来看看... -
@kindall 这对调试很有用,但我需要以编程方式进行,以便每次在后端都能正常工作
-
是的,但是通过调试,您可以轻松地了解如何以编程方式执行此操作,通过查看您获得的内容,这将决定如何访问它。
-
您使用的是
webapp还是webapp2?它们用于从请求中获取多个值的 API 略有不同。
标签: python html google-app-engine checkbox webapp2