I have a CheckboxSelectMultiple
in a Django form like this :
forms.py
LIST= [
('Oranges', 'Oranges'),
('Cantaloupes', 'Cantaloupes')
]
testrever = forms.MultipleChoiceField(required=False,widget=forms.widgets.CheckboxSelectMultiple(choices=LIST)`)
I would like to get the Checkboxes value, each time that one of them is there is selected / unselected to populate another field of the form (email).
This is what I got so far but I can't retrieve the chekboxes value :
template.py
<script>
$(function(){
$('#id_testrever').change(function(){
var a = $("#id_email").val();
if ($("#id_testrever").val() == "Oranges")
$("input[name=email]").val(a + "Oranges")
if ($("#id_testrever").val() == "Mangoes")
$("input[name=email]").val(a + " Mangoes")
});
});
</script>