Hi! I am trying to filter drop down list with the help of choosen plug in, its working fine for first row. But when I clone or dynamically create more row, then drop down list become inactive and and displaying selected value of first row in all new dynamic rows. Below is the my code . I needed guidance to resolve this issue
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Medicine Re-Location Form</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
</head>
<body>
<div class="container">
<div class="card">
<h3 div class="card-header" style="background-color: #3fbbc0;">Request Form</h3>
<div class="card-body">
<form method="POST" action="invoice.php">
<div class="card-body">
</div>
<table class="table table-bordered">
<thead class="table-success" style="background-color: #3fbbc0;">
<tr>
<th width="15%"><center>Product</th>
<th width="10%"><center>Qty (No)</th>
<th width="20%"><center>Remarks</th>
<th width="5%"></th>
<button type="button" class="btn btn-sm btn-success" onclick="BtnAdd()">Add Item</button>
</th>
</tr>
</thead>
<tbody id="TBody">
<tr id="TRow" >
<div class="col-lg-4"><div class="form-group">
<td><Select class="scode form-control text-end" name="scode[]" id = "scode" class="form-control" required onchange="GetDetail(this.closest('tr'))">
<option value="">Select Product</option>
<?php
include('db.php');
$sql = mysqli_query($con,"SELECT * FROM procd2");
while($row=mysqli_fetch_array($sql))
{
echo '<option value="'.$row['pro1'].'">'.$row['pro1'].'</option>';
} ?></select>
</td>
<td><input type="text" class="qty form-control text-end" name="qty[]" id="ccc" pattern="\d+"></td>
<td><input type="text" class="form-control text-end" name="remarks3[]" id="zzz" ></td>
<td class="NoPrint"><button type="button" class="btn btn-success" style="line-height: 1;" onclick="BtnDel(this)">x</button></td>
</tr> </tbody> </table>
<script>
jQuery('.scode').chosen();
</script>
<div class="col-lg-4"> <div class="form-group"><center>
<input type="submit" name="submit" id="submit" value="Submit" class="btn btn-success submit_btn invoice-save-btm">
</form>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="frontend-script.js"></script>
</body>
</html>
<script type="text/javascript">
function GetPrint()
{
/*For Print*/
window.print();
}
function BtnAdd()
{
/*Add Button*/
var v = $("#TRow").clone().appendTo("#TBody") ;
$(v).find("input").val('');
$(v).find("input").autocomplete({
source: 'backend-script.php'
});
$(v).removeClass("d-none");
$(v).find("th").first().html($('#TBody tr').length - 1);
}
function BtnDel(v)
{
/*Delete Button*/
$(v).parent().parent().remove();
GetTotal();
$("#TBody").find("tr").each(
function(index)
{
$(this).find("th").first().html(index);
}
);
}