skip to Main Content

I have a form with two input type=text fields outside the form tags. I’m using the HTML5 form attribute on the input fields. In my PHP $_POST I get the original values, regardless of what I type in the input (09:00 and 13:00 in the example below).
I tried in both Chrome and Firefox, with the same result.
What am I doing wrong?

<table>
  <tbody>
    <tr>
      <td>
        28 Aug 2024 <input type="text" name="etd" value="09:00" form='41139'>
      </td>
      <td>
        28 Aug 2024 <input type="text" name="eta" value="13:00" form='41139'>
      </td>
      <td>
        <form action="itinerary.php" method="post" id="41139">
          <input type="submit" name="submit" value="Save">
        </form>
      </td>
    </tr>
  </tbody>
</table>

2

Answers


  1. this problem might be due to browser caching or how the "form" attribute is handled
    Try disabling caching with <meta http-equiv="Cache-control" control ="no-cache">

    you can use JavaScript to ensure the update value are submitted

    Login or Signup to reply.
  2. as mplungjan pointed in his comments :
    1 – it could be an issue of a numeric ID -> change id="41139" to id="f41139"
    2 – NEVER call anything in a form.name or form.id submit

    <table>
      <tbody>
        <tr>
          <td>                      
            28 Aug 2024 <input type="text" name="etd" value="09:00" form='f41139'>
          </td>
          <td>
            28 Aug 2024 <input type="text" name="eta" value="13:00" form='f41139'>
          </td>
          <td>                  <!-- don't use numéric for id --> 
            <form action="itinerary.php" method="post" id="f41139">
              <input type="submit" value="Save"> <!-- name="submit" removed --> 
            </form>
          </td>
        </tr>
      </tbody>
    </table>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search