Python cherrypy中的复选框值
我知道Cherrypy将复选框值作为列表问题()提供 假设我有以下表单数据:Python cherrypy中的复选框值,python,checkbox,cherrypy,Python,Checkbox,Cherrypy,我知道Cherrypy将复选框值作为列表问题()提供 假设我有以下表单数据: ... snip ... <input type=checkbox id="1"> <input type=checkbox id="1"> <input type=checkbox id="1"> <input type=checkbox id="2"> <input type=checkbox id="2"> <input type=checkbo
... snip ...
<input type=checkbox id="1">
<input type=checkbox id="1">
<input type=checkbox id="1">
<input type=checkbox id="2">
<input type=checkbox id="2">
<input type=checkbox id="2">
<input type=checkbox id="3">
<input type=checkbox id="3">
<input type=checkbox id="3">
... snip ...
从我取消选中第二个复选框id3的那一刻起,我得到:
{'1': [u'on', u'on', u'on'],'2': [u'on', u'on', u'on'],'3': [u'on', u'on']}
有了这个,我无法说哪个复选框是未选中的。。。。我可以在复选框未选中时使用“off”时使用。。但事实并非如此
有没有办法解决这个问题
干杯
Jay首先是一个nit:HTML中的“id”属性对于整个文档来说应该是唯一的
然后您有两个选项:
,在这种情况下,您将返回{…,'3a':u'on''3c':u'on'}
,或
,在这种情况下,您将返回{…,'3':[u'a',u'c']}
我担心事情会归结到这一点。我会选择选项1。谢谢
{'1': [u'on', u'on', u'on'],'2': [u'on', u'on', u'on'],'3': [u'on', u'on']}