admin管理员组文章数量:1325236
I have a form that contains a date picker. The date picker works fine, but when I want to submit its value to the PHP script it, doesn't show. Here is the relevant part of my HTML code:
<body>
<form action="sub.php" method="post">
<h2>JsDatePick's Javascript Calendar usage example</h2>
Look at the ments on the HTML source to fully understand how this very simple example works.
<input type="text" size="12" id="inputField" name="inputField" />
<input type="submit" value="submit">
</form>
</body>
And I want to pick the date value from inputField
in this script:
<?php
echo $date=$_POST['inputField'];
?>
So can you guys tell me how can I get this value from the HTML to the PHP script? I did not show the code of the date picker because that works fine. Thanks in advance.
I have a form that contains a date picker. The date picker works fine, but when I want to submit its value to the PHP script it, doesn't show. Here is the relevant part of my HTML code:
<body>
<form action="sub.php" method="post">
<h2>JsDatePick's Javascript Calendar usage example</h2>
Look at the ments on the HTML source to fully understand how this very simple example works.
<input type="text" size="12" id="inputField" name="inputField" />
<input type="submit" value="submit">
</form>
</body>
And I want to pick the date value from inputField
in this script:
<?php
echo $date=$_POST['inputField'];
?>
So can you guys tell me how can I get this value from the HTML to the PHP script? I did not show the code of the date picker because that works fine. Thanks in advance.
Share Improve this question edited Aug 31, 2012 at 14:23 Ashley Strout 6,2686 gold badges27 silver badges48 bronze badges asked Aug 31, 2012 at 14:15 HarshalHarshal 3,6229 gold badges39 silver badges67 bronze badges 8-
You're missing your closing
</form>
tag – Cfreak Commented Aug 31, 2012 at 14:16 - no i am not showing the full html code – Harshal Commented Aug 31, 2012 at 14:17
- When you click the input field then click a date on the calendar, does the date actually appear in the textbox? – Ashley Strout Commented Aug 31, 2012 at 14:18
-
1
var_dump($_POST);
And see what's inside. – Leri Commented Aug 31, 2012 at 14:19 - @D.Strout yes it shows correct value – Harshal Commented Aug 31, 2012 at 14:19
2 Answers
Reset to default 4<?php
$date = $_POST['inputField'];
echo $date;
?>
this is the datepicker
<form action="" method="POST">
<input type="date" name="date">
<input type="submit" name="submit" value="submit">
</form>
and all the PHP code you need to get up and running is this
<?php
if(isset($_POST['submit'])) {
$date = $_POST['date'];
echo $date;
}
?>
this code $date = $_POST['date'];
gets the value of the date picker
and this code echo $date;
prints out the date you picked
本文标签: javascriptGet value of date picker in PHP codeStack Overflow
版权声明:本文标题:javascript - Get value of date picker in PHP code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742167802a2426152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论