vendredi 6 février 2015

Passing a Tuple of Values through a Checkbox

I have a list of organized items that users may choose from using checkboxes. I am trying to pass a tuple of values for each checked checkbox so I can get information about the item itself and the group to which the item belongs. I have tried using hidden fields but it seems that the hidden field value is being passed regardless of if the corresponding checkbox has been checked or not.


If a checkbox is checked, I need the citation id and the parent software. Can I pass a tuple of (citation.id, sw) for each checked checkbox and, because multiple checkboxes can be checked, pass all of these together as a list of tuple? Like: [(citation1.id, sw1), (citation2.id, sw2), ] ? I need this info in my view.


Thank you for any help!


select_citations.html



{% for sw in software %}
{{sw}}
{% for citation in all_citations %}
<input type="checkbox" name="myselection[]" value="{{citation.id}}">
<input type="hidden" name="myselection[]" value="{{sw}}">
{% endfor %}
{% endfor %}




Aucun commentaire:

Enregistrer un commentaire