Reputation: 87
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?
Upvotes: 1
Views: 420
Reputation: 30414
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.
Upvotes: 0
Reputation: 251262
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.
Upvotes: 4
Reputation: 3654
No there is not, however you can put all the attributes you need in hidden fields which are passed with form.
Upvotes: 0