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
CodePudding user response:
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();">
CodePudding user response:
You're not using standard double quotes "
, but a curly variant, which are not part of the HTML standard:
value=”<?php echo $_POST['Date'];?>”
Replacing those curly quotes by straight ones will fix your problem.
CodePudding user response:
This will work as well, copy below code as there is quote issue in your code:
<input type="date" id="Date" name="Date" placeholder="Date" value="<?php echo $_REQUEST['Date']?>" onchange="this.form.submit();">