I am messing around with a tornado web app with which I need a bit of help. I have multiple checkboxes with the same name and I would like to POST the values of the selected one.
<input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/>
<input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/>
<input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/>
<input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/>
I can get the values of each with javascript pre-POST but am having troubles getting this list on the python (tornado) side. i only get the highest selected value.
on the python side it looks like:
...
def post(self):
email = self.get_argument("email")
activity = self.get_argument("activity")
It's fine to let multiple tags have the same name attribute, but the id
attributes must be unique -- here, they're not (unless each of those occurrences of the identical DB_BASED_ID
is somehow meant to be replaced with a different value? But then why not show the things actually distinct, as they do appear in the real HTML?!), making this invalid HTML and subject to all sorts of problems.
Once this problem is fixed, in those handler methods, self.request.arguments['activity']
(if that string key is present in said directory) will be a list of non-empty values for all inputs named 'activity'
(if any).