Saturday, 14 September 2013

How to create a button toggle with two states, that behaves like a checkbox for form input

How to create a button toggle with two states, that behaves like a
checkbox for form input

I want to use bootstrap buttons
(http://getbootstrap.com/javascript/#buttons) to create a checkbox-like
input, with two states:
One that displays a button with "Option A selected"; and
The other that displays "Option B selected".
When the button is clicked, I want it to toggle between these two
messages, but also be able to pass the selection to the form.
What's the best way to do this? My first thought was to try and mark-up
data-toggle="button", but I'm not convinced this is the easiest way. Any
ideas?

No comments:

Post a Comment