i have following part of code:
<input id="add" class="add" data-amount="150" data-monthly="25" type="checkbox" name="accessory[]" value="Accessory Name"/>
wondering if there any way to post all data in "value", "data-amount" and "data-monthly" together to another script?
-
2Without using jQuery or some JavaScript, no.BenM– BenM2012-06-07 15:08:45 +00:00Commented Jun 7, 2012 at 15:08
4 Answers
If you are writing the value of those attributes onto the page server side, you are better off working off of a key and retrieving the values again server side based on the key. The HTML could be altered resulting in non-trustworthy data being send back.
For example...
<input id="add" class="add" data-amount="150" data-monthly="25" type="checkbox" name="accessory[]" value="1"/>
Where 1 is the id of the data that contains the amount and monthly data.
7 Comments
data-amount="0" won't I get it for free?To get all those values in the checkbox, you can concatenate them together separated by some delimiter and then split the value when processing the form.
<input type="checkbox" name="accessory[]" value="Accessory Name*150*25"/>
This is not an elegant solution. It does what you ask, but you should strongly consider Sohnee's answer as a better method of doing what you want to do.