我知道Cherrypy使复选框值可用作listcfg问题(CherryPy - saving checkboxes selection to variables)
假设我有以下表单数据:
... 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 ...
然后Cherrypy将其作为:
^{pr2}$从我取消选中第二个复选框id3的那一刻起,我得到:
{'1': [u'on', u'on', u'on'],'2': [u'on', u'on', u'on'],'3': [u'on', u'on']}
有了这个,我无法说出哪个复选框没有被选中。。。。我可以在复选框未选中时使用'off'。。但事实并非如此。在
有什么办法解决这个问题吗?在
干杯
杰伊
首先一点:HTML中的“id”属性对于整个文档来说应该是唯一的。在
然后您有两个选择:
<input type="checkbox" name="3b">
,在这种情况下,您将返回{..., '3a': u'on' '3c': u'on'}
,或者<input type="checkbox" name="3" value="b">
,在这种情况下,您将得到{..., '3': [u'a', u'c']}
。在相关问题 更多 >
编程相关推荐