Skip to content Skip to sidebar Skip to footer

How To Parse Value From Popover To Textbox?

I want to parse value from dropdown box inside a popover to the input text. I can make it pop but cannot insert the selected value. I don't need a select in a popup for some reason

Solution 1:

You were binding the element in wrong way. Try this -

$(document).on('click','#optBtn',function() {//can be hide after selectvar selectVar = $('#select').find('option:selected').val();
    alert(selectVar)
    $('#input').val(selectVar);
})

Solution 2:

Hi You can try on this.

$("[data-toggle=popover]").popover({
  html: true,
  content: function() {
    return $('#popover-content').html();
  }
}).parent().delegate('#optBtn', 'click', function() {
    var selectVar = $('#select').val();
     $('#input').val(selectVar);
     alert(selectVar);
}); 

Solution 3:

Thanks to @nikhil_gandhi and @PhaniKumarM for the helps. The final code as below:

$("[data-toggle=popover]").popover({
  html: true,
  content: function() {
    return $('#popover-content').html();
  }
});
$(document).on('click','#optBtn',function() {//can be hide after selectvar selectVar = $('#select').find('option:selected').val();
    $('#input').val(selectVar);
    $('.popover').hide();
})

https://jsfiddle.net/723exh1g/17/

Post a Comment for "How To Parse Value From Popover To Textbox?"