use bootstrap switch to reveal a textfield or other input
Hi, Im trying to integrate http://jsfiddle.net/brL6gy7r/ with bootstrap switch to reveal a textfield when switch is set to yes (checkbox is checked). Wondering if u know how? Thanks
For future reference this question is better posted on StackOverflow as Github Issues are for tracking bugs.
BootstrapSwitch works by having one checkbox. I accomplish what you want with two input fields available in my HTML code but hiding one of them by default. Then based on the state ('checked' or 'unchecked') of the checkbox, hiding textfield1 and displaying textfield2. In general it is bad practice to bind javascript functions to click events inline. my example (using jquery) HTML: ''' <input type="text" id="textarea1 /> ''' JS: ''' $('.checkbox').on('change', function() { $textarea1 = $('#textarea1') $textarea2 = $('#textarea2') if ($(this).prop('checked') == true) { $textarea1.hide() $textarea2.show() } else { $textarea1.show() $textarea2.hide() } }) '''