Is it legitimate to store a JSON object as the value attribute of a checkbox input?
html, jquery, json
Solution
You can use HTML5 `data-*` attribute:
<input type="checkbox" data-value='{"id": 100, "postcode": "WA8 6QF"}' />
var val = $('input:checkbox').data('value')
Problem
I have a HTML table from which the user will check the row if they want to perform a particular action on that row. Rather than creating logic which picks out the key data from the row I wish to store the key values in the value attribute of the input checkbox. My question is, is this legitimate: ``` <input type="checkbox" value="{'id': 100, 'postcode': 'WA8 6QF'}" /> ``` This way I can use jQuery selectors to pick out the checked boxes and loop through them, performing the action using the items in the value JSON object.