I have been trying to call the selected value from the option by using JQuery but it keeps on passing the default value only. The option select was set using JQuery as when the edit button is pressed, the field changes to select.
i have tried this :
$("#tstSelected option").filter(":selected").val();
and this:
$( "#tstSelected option:selected" ).text();
and none seemed to work
if($(this).hasClass('fa-pencil')){
$.each(currentTD, function () {
if($(this).hasClass('editable')){
if($(this).hasClass('getFromSelect')){
//$(this).prop('contenteditable', false);
$(this).html("<select>" + "<?php foreach($test as $tst){ echo "<option id='tstSelected' value='$tst->tst_idx'>". $tst->tst_desc . $tst->tst_idx ."<option>"; } ?>" + "</select>");
}
$(this).prop('contenteditable', true);
}
});
$(this).removeClass('fa-pencil')
.addClass('fa-check')
editing = true;
}
then I'm calling the selected value like this:
$("#tstSelected option").filter(":selected").val();
but it's not working
I am just getting the default value only which is the value of the first selected value