Form submit button in a DataTable not working as subarray

Hello i am using a datatable to retrive data with dynamic table data. using subarray to fetch data . i have included a form to that aray but the form function is not working whene i script to the fetch file. please help me with this.

    <?php
session_start();
// $id = $_SESSION['id'];
//fetch.php
$connect = mysqli_connect('localhost', 'sbcldb_management', 'management_server2021', 'sbcldb_management');
$columns = array('C_Number', 'coupon', 'date', 'District','Upazilla','storename','eye');
$query = "SELECT * FROM code_genarate WHERE status='1' ";
if(isset($_POST["search"]["value"]))
{
 $query .= 'AND
  (C_Number LIKE "%'.$_POST["search"]["value"].'%"
  OR coupon LIKE "%'.$_POST["search"]["value"].'%"
  OR date LIKE "%'.$_POST["search"]["value"].'%"
  OR District LIKE "%'.$_POST["search"]["value"].'%"
  OR Upazilla LIKE "%'.$_POST["search"]["value"].'%"
  OR storename LIKE "%'.$_POST["search"]["value"].'%")
  ';
}

if($_POST["district"] != '')
{
$did = $_POST["district"];
$sql = "SELECT * FROM districts WHERE id = '$did'";
$res = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($res))
{
  $district = $row['district'];
}
$uid = $_POST["upazilla"];
if($uid > 0){
  $sql = "SELECT * FROM upazilla WHERE id = '$uid'";
  $res = mysqli_query($connect, $sql);
  while($row = mysqli_fetch_array($res))
  {
    $upazilla = $row['upazilla'];
  }
 $query .= "AND District='$district' AND Upazilla= '$upazilla'";
 }else{

 $query .= "AND District='$district'";
 }

$query1 = '';

if($_POST["length"] != -1)
{
 $query1 = 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}

$number_filter_row = mysqli_num_rows(mysqli_query($connect, $query));

$result = mysqli_query($connect, $query . $query1);

$data = array();
// $total = 0;
while($row = mysqli_fetch_array($result))
{
  // $total += $row["Amount"];
  $sub_array = array();
  // $sub_array[] = '<a href="../customers/customerdetails.php?id='.$row['C_Number'].'">'.$row['C_Number'].'</a>';
  // $sub_array[] = $row["Amount"];;
  // $sub_array[] = $row["SaleDate"];
  $sub_array[] = $row["C_Number"];
  $sub_array[] = $row["coupon"];
  $number = $row['C_Number'];

  $sub_array[] = $row["date"];
  $sub_array[] = $row["District"];
  $sub_array[] = $row["Upazilla"];
  $sub_array[] = $row["storename"];

  $sub_array[] = '<form name="submit-to-gateway" id="myForm">
  <div id="form_alerts"></div>
  <div class="row">
    <div class="col-8">
  <input type="hidden" name="text" value="Dear Retailer, Your Software Download link is http://sbcldb.ltd/application/sbcldb.apk  ,With the best Regards, SBCLDB LIMITED." </input>
  <input type="text" class="form-control" name="number" value="'.$row['C_Number'].'"/>
  </div>
  <div class="col-4">
  <button class="btn btn-primary" type="submit" class="form-control" id="sms_btn" name="sms_btn">Send</button>

</div>
</div>
  </form>';
  $data[] = $sub_array;
}
function get_all_data($connect)
{
$quer = "SELECT * FROM retailer_sales";
 $result = mysqli_query($connect, $quer);
 return mysqli_num_rows($result);
}

$output = array(
 "draw"    => intval($_POST["draw"]),
 "recordsTotal"  =>  get_all_data($connect),
 "recordsFiltered" => $number_filter_row,
 "data"    => $data
);




echo json_encode($output);



<script>
  const scriptURL = 'https://script.google.com/macros/s/AKfycbzfMQmBwDEO8k0H8jeLlKTE_GzK0XuQ1unZd_5ib_DDBhM17b6FVahIW5f3W4FyfCNOAw/exec'
  const form = document.forms['submit-to-gateway']

  form.addEventListener('submit', e => {
    e.preventDefault()
    fetch(scriptURL, {
        method: 'POST',
        body: new FormData(form)
      })
      .then(response => $("#form_alerts").html("<div class='alert alert-success'>Id Sent Successfully.</div>"))
      .catch(error => $("#form_alerts").html("<div class='alert alert-danger'>Id Could not be Sent.</div>"))
      $('#myForm')[0].reset();
  })
</script>


?>

the form is submitting on a html page perfectly but i cant merger this to the datatable.
please help me with this.