Home > Mobile >  Keep the date value in a html form after it has been submitted
Keep the date value in a html form after it has been submitted

Time:03-15

I have created this form which I have placed in the Wordpress divi theme code module on a page. It is used to return the stock availability for my shop that is connected to a 3rd party api.

After the form is submitted how do I get it to keep displaying the values that were submitted.

<p>Enter your Event Dates</p><br>

<form  action="" method="post">

<span>
  <label for="date_from">Date From:</label>
  <input type="date" id="date_from" name="date_from" value="dd-MM-YYY">
</span>

<span>
  <label for="date_to">Date To:</label>
  <input type="date" id="date_to" name="date_to" value="dd_MM-YYY"><br>
</span>

<input type="submit">
</form>

CodePudding user response:

This way:

<input type="date" id="date_from" name="date_from" value="<?php echo isset($_POST['date_from'] ? $_POST['date_from'] : '' ?>">

CodePudding user response:

You can try writing a new script under all javascript definitions. Page must .php

<script>
document.getElementById("date_from").value = '<?php echo isset($_POST['date_from'] ? $_POST['date_from'] : '' ?>';
  • Related