Hi,
I have a script that I used to insert the values from another drop down into table drop down
$('.btn').on('click',function(){ //add row when button is clicked $('.timesheet .cf-table-add-row').trigger('click'); // add all options with values to the list var ddlArray = []; $('.leavereason option').each(function(){ ddlArray.push($(this).val()); }); // array sort ddlArray.shift(); ddlArray.sort(); // add the new options $.each(ddlArray,function(index,value){ $('.cf-table-block tbody tr').each(function () { $(this).find('.jobtype select').append($('<option></option>') .attr('title',value) .attr('value',value) .text(value)); }); });
It works fine until I add a second row to the table. The drop down in the first row double while the second row is as expected.
This is the leave reason option field which is being populated by the database. The script copy the data from this field into the jobtype field in the table.
This is the second row
This is the first row
How can I prevent the data from the drop down being added to the first row?