I read all these topics:
How do I get multiple values from checkboxes in Django
How do I get the values of all selected checkboxes in a Django request.POST?
Get the values of multiple checkboxes in django
I implemented a code, but still it doesnt work correctly. So I need to get value of checkbox where it was selected. My code:
VIEW
def get_context_data(self, **kwargs):
.......
context['checkedd'] = self.request.POST.getlist('checks[]')
return context
HTML:
<button class="btn btn-default" onclick="myFunction()">
<span class="glyphicon"></span> Get checked values
</button>
....
<td> <input type="checkbox" name="checks[]" value='{{ i.id }}'> </td>
....
<script>
function myFunction() {
alert({{ checkedd }});
}
</script>
Im trying to print out/ make an alert message of selected values, but the answer is empty. Please help a noob.
Aucun commentaire:
Enregistrer un commentaire