I have a form with a table inside it. The table has four input elements each with type=submit. The form also has a hidden input element. What I want to do is the following:
When one of the four input elements is clicked, a jQuery event should fire that:
- Stops submission
- Sets the id of the clicked element as the value of the hidden input
- Submits the form
The event is not firing and the form is being submitted normally. I can't see what the issue is. Any help is appreciated.
<form id="myForm" method="post" action="" style="background-color: antiquewhite; margin: 0; padding: 0;">
  {% csrf_token %}
  <input type="hidden" id="op" name="op" value="">
  <table align="center" style="width: 100%;" border="1" style="background-color: antiquewhite; margin: 0; padding: 0;">
    <tr>
      <td rowspan="2">
        <h3>Is this an <i>origin</i> for the <i>claim?</i></h3>
      </td>
      <td><input type="submit" id="1" value="Yes"></td>
      <td><input type="submit" id="2" value="No"></td>
    </tr>
    <tr>
      <td><input type="submit" id="3" value="Invalid Input"></td>
      <td><input type="submit" id="4" value="Don't Know"></td>
    </tr>
  </table>
</form>
$("input").on('click', function(e) {
  e.preventDefault();
  let choice = e.target.id;
  document.getElementById("op").value = choice;
  $("#myForm").submit();
});
 
     
     
    