Reputation: 949
Is there a way so i can set a html checkbox with a bidimensional array, something like this:
<input type=checkbox name=message[group1][1] value=1>
If yes,
1) how should I do to accomplish that in case the example I wrote is wrong?
2) how could I access those elements from a request handler in django?
Upvotes: 0
Views: 103
Reputation: 4761
Yes, you can use such checkboxes names, ultimately it's just a string. To get all elements on server side you could generate checkboxes names and get its values. Like this:
def multi(request):
arr = []
for x in range(1, 6):
cur_row = []
arr.append(cur_row)
for y in range(1, 6):
curr_cell = bool(request.POST.get('message[group%d][%d]' % (x, y)))
row.append(curr_cell)
return HttpResponse('ok')
But server needs to know what ranges will come to process all checkboxes. I set 1..5 range for example.
PS. Is value
attribute as valid for checkboxes? What about checked
attribute?
Upvotes: 1