I have a table has input column and drop down menu column with class's test1, test2. I need to make a match between input and first 5 characters in options in drop down menu, if it match select this option.
for example: if i write "00001" select "00001-Test1" as a selected option.
Here what i tray but it not working:
$(document).ready(function(){
selectFromDdm();
$('.tbl1').on('change', selectFromDdm);
function selectFromDdm() {
$('.tbl1 tbody tr').each(function () {
$(this).find('.test1 input').each(function () {
var inputVal = $(this).closest('tr').find('.test1 input').val();
$('.test2 select').each(function(){
var sb1_option = $(this).closest('tr').find('.test2 select').val().substr(0,5);
if(inputVal == sb1_option){
var selected = $(this).closest('tr').find('.test2 select').val();
$(".test2 select").val(selected);
}else{
}
});
});
});
}
});