PHP Foreach Loop with Form Fields only submitting first entry

I am trying to display a list and when a user clicks on an item on the list it will submit a form with a hidden field and value. Now my issue is I can easily just use a submit button next to the list button and submit. However, I want to keep away from the tradition submit button. I incorporated some javascript to submit the form when I click a div. Unfortunately my problem now is that it will only submit the first entry in my list when clicked. If I try to click on anything other than the first entry the form does not submit at all. I’m think this might have something to do with the form having to have a unique id or something? I’m not too sure. Any help will be greatly appreciated.

<?php 
$listchars = $user->getCharacterList($_SESSION['user_id']); 
foreach($listchars as $chardata){
  $cid = $chardata['cid'];
  $pic = $chardata['picture'];
  ?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" name="char-select-form" id="char-form">
<input type="hidden" name="cid" value="<?php echo $cid;?>">
</form>
<div class="submit"><?php echo $chardata['name']; ?></div>
<?php
}
?>



<script>
 const myForm = document.getElementById("char-form");
document.querySelector(".submit").addEventListener("click", function(){

  myForm.submit();

});
 </script>

Answer

<?php 
$listchars = $user->getCharacterList($_SESSION['user_id']);
foreach($listchars as $chardata){
  $cid = $chardata['cid'];
  $pic = $chardata['picture'];
  ?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" name="char-select-form" class="class-char-form">
<input type="hidden" name="cid" value="<?php echo $cid;?>">
<div class="submit"><?php echo $chardata['name']; ?></div>
</form>
<?php
}
?>



<script>
  var allForms = document.querySelectorAll(".class-char-form");
  for (var i = 0; i < allForms.length; i++) {
    allForms[i].querySelector(".submit").addEventListener("click", function(){
      this.parentNode.submit();
    });
  }
 </script>