HTML5 Data Toggle Buttons [FORM]
HTML
<div data-toggle="buttons-radio">
<button type="button" class="btn" id="yesBtn" data-info='{"post":"1"}'>Yes</button><button type="button" class="btn" id="noBtn" data-info='{"post":"0"}'>No</button>
</div>
HIDDEN FIELD
<input type="hidden" id="post_to_fb" name="post_to_fb" value="">
jQuery
$('#yesBtn').click(function(e) {
e.preventDefault();
thisdata = $('#yesBtn').data('info').post;
//console.log(thisdata);
$("#post_to_fb").val(thisdata);
});
$('#noBtn').click(function(e) {
e.preventDefault();
thisdata = $('#noBtn').data('info').post;
//console.log(thisdata);
$("#post_to_fb").val(thisdata);
});
Written by Wayne Roddy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#