Search code examples
phphtmlonchange

PHP keep input type=date value after form submit


i want to keep my input type=date value after onchange form submit

Current HTML code

             <input type="date" id="Date" name="Date" placeholder="Date" value=”<?php echo $_POST['Date'];?>” onchange="this.form.submit();">

So after onchange, I want the value of the date remain same. I tried many ways but it didn't work. Thanks for helping


Solution

  • Please check with this, I am seeing issue with quote as well in your HTML, so copy below code to see.

    <input type="date" id="Date" name="Date" placeholder="Date" value="<?php echo isset($_REQUEST['Date'])?date("Y-m-d",strtotime($_REQUEST['Date'])):'';?>" onchange="this.form.submit();">