You are viewing limited content. For full access, please sign in.

Question

Question

How to set option in drop down list in table as selected after substring

asked on February 1, 2019 Show version history

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{
          }
        });
      });
    });
  }
});

0 0

Replies

replied on February 2, 2019

Hi Mahmoud

My recommendation would be to use a stored procedure for your query as opposed to trying to script

0 0
replied on February 2, 2019

I have a specific case that i have to run using jquery, I try this code it working when i run in a fields but in Laserfiche table not working.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.