Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从日历日期选择器获取所选日期_Php_Jquery_Calendar_Datepicker - Fatal编程技术网

Php 从日历日期选择器获取所选日期

Php 从日历日期选择器获取所选日期,php,jquery,calendar,datepicker,Php,Jquery,Calendar,Datepicker,我需要从日历日期选择器获取所选日期的帮助。目前我可以选择从…到…的日期。。。并将其放入文本框中。但我无法获取要放入PHP变量的值 <head> <meta charset="utf-8" /> <title>jQuery UI Datepicker - Select a Date Range</title> <link rel="stylesheet" href="http://code.jquery.com/ui

我需要从日历日期选择器获取所选日期的帮助。目前我可以选择从…到…的日期。。。并将其放入文本框中。但我无法获取要放入PHP变量的值

<head>


    <meta charset="utf-8" />
    <title>jQuery UI Datepicker - Select a Date Range</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
        $(function() {
            $( "#from" ).datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 3,
                onClose: function( selectedDate ) {
                    $( "#to" ).datepicker( "option", "minDate", selectedDate );
                }
            });
            $( "#to" ).datepicker({
                defaultDate: "+1w",
                changeMonth: true,
                numberOfMonths: 3,
                onClose: function( selectedDate ) {
                    $( "#from" ).datepicker( "option", "maxDate", selectedDate );
                }
            });


        });
    </script>
</head>
<body>


        <label for="from">From</label>
        <input type="text" id="from" name="from" />


        <label for="to">to</label>
        <input type="text" id="to" name="to" />

</body>

在提交该表单时,您可以从您为日期指定的输入名称中获得该表单。i、 e$_POST['from']和$_POST['to'])。

您没有要提交的表格。您应该首先创建一个表单,如下所示:

<form action="foo.php" method="post">

    <label for="from">From</label>
    <input type="text" id="from" name="from" />


    <label for="to">to</label>
    <input type="text" id="to" name="to" />

    <input type="submit" value="Submit dates">
</form>

要在PHP中检索该值,可以通过两种方式进行。 1> 通过放置表单和提交按钮,并在POST中获取这些值。
2> 第二个是通过AJAX调用输入框的模糊事件。

在提交后将其放入表单中,您将在$\u POST[form]和$\u POST[to]中获得值。这正是我所需要的!非常感谢您:当您提交表单时,您可以使用print\u r$\u post检查post值;f-k。他只要求提供日期值
$from = $_POST['from'];
$to = $_POST['to'];