bootstrap-switch icon indicating copy to clipboard operation
bootstrap-switch copied to clipboard

use bootstrap switch to reveal a textfield or other input

Open hcanning2014 opened this issue 8 years ago • 1 comments

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

hcanning2014 avatar Aug 08 '17 23:08 hcanning2014

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() } }) '''

k4m1113 avatar Sep 05 '17 00:09 k4m1113