I have used editable select Jquery plugin,now the problem is i want the currently selected value of editable select control with out on change or other event
link to Editable select
I have tried following till now but no success
$('#customer_name').find('li.selected').value()
$('#customer_name').siblings('.es-list').find('li.selected').value()
$("#customer_name").val();
HTML
<select id="customer_name" name="customer_name" class="form-control">
<?php
foreach($customers as $customer){
echo "<option value='".$customer['cust_id']."'>".$customer['cust_name']." </option>";
}//foreach
?>
</select>
$('#customer_name').editableSelect();
I have dome some R&D regarding this question and I have found something which helps me to achieve the goal. So, I am sharing the Jquery code with the Link so that you can get more information.
Jquery code for getting the selected value:
$('#onselect')
.editableSelect()
.on('select.editable-select', function (e, li) {
console.log('Seletced Value: ');
console.log(li.val() + '. ' + li.text());
});
Ref. Website Jquery Editable Select Example
Thanks.
Try this
const x = $('#customer_name').attr('value')
this should work.
if this doesn't work, then your HTML element doesn't have an attribute called value, try adding a value & id to any HTML element then do $(id).attr('value') and you'll get the value attribute
I have read the docs but i could't find any solution so what i have done is stored the value of editable select in hidden filed for the first time and when user change the value then i have jquery to update the value. if any one has solution please mention
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.