-1

I have a select combo box here. What I need is the input text box to appear when other option is selected in select box. I have been using bootstrap select tag.

  <select name="store_name" id="store_name"  class="selectpicker" data-width="100%">
    <option value="" disabled="disabled" >Please select</option>
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Other">Other</option>
  </select>

  <input type="text" id="store_name" name="store_name" value="" class="form-control" />
Khanh Tran
  • 1,776
  • 5
  • 25
  • 48
Kay
  • 498
  • 3
  • 14

1 Answers1

0
        $('#pasveids').on('change', function(e){
            if(e.val == 'Value if clicked on other') {
                $('#hiddenevent').attr('type', 'text');
                $('#pasveids').attr('name', '');
                $('#hiddenevent').attr('name', 'eventtype');


            } else {

                $('#hiddenevent').attr('type', 'hidden');
                $('#pasveids').attr('name', 'eventtype');
            }
        });

id=pasveids is my select box! (using select2 plugin js), but may work for other too!

id=hiddenevent is input field which is hidden at start, and when you click on dropdown, which e(event).val == it shows it, if click other, hides!

Michael
  • 321
  • 2
  • 13