在php中显示jquery datepicker值

时间:2014-04-18 04:55:47

标签: php jquery datepicker

我有一个带有datepicker的表单,我想将所选日期传递给我的php文件,但它似乎不起作用。

我的HTML就像这样

<form method="post" action="http://www.domainname.com/?from=20/04/2014&to=25/04/2014" name="easy_widget_form" id="easy_widget_form">
<div class="input_container">
    <div class="input_prefix">
        Check in:
    </div><input id="easy-widget-datepicker-from" type="text" name="from" value="20.04.2014" class="hasDatepicker">
</div>
<div class="input_container">
    <div class="input_prefix">
        Check out:
    </div><input id="easy-widget-datepicker-to" type="text" name="to" value="25.04.2014" class="hasDatepicker">
</div>
    <p class="easy-submit"><input type="submit" class="easybutton" value="Reserve now!"> </p>
</form>

Javascript:

jQuery('#easy-form-from,#easy-widget-datepicker-from').val(d);

但是当我在我的php文件中回显$ easy-widget-datepicker-from时,它没有显示任何内容。任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:1)

将您的网页设为此

<强> contact.php

<?PHP
if($_REQUEST['Submit']=='Reserve now!'){
        echo $from= $_POST['from'];
        echo $to= $_POST['to'];
}
?>
<form method="post" action="contact.php" name="easy_widget_form" id="easy_widget_form">
<div class="input_container">
    <div class="input_prefix">
        Check in:
    </div><input id="easy-widget-datepicker-from" type="text" name="from" value="20.04.2014" class="hasDatepicker">
</div>
<div class="input_container">
    <div class="input_prefix">
        Check out:
    </div><input id="easy-widget-datepicker-to" type="text" name="to" value="25.04.2014" class="hasDatepicker">
</div>
    <p class="easy-submit"><input name="Submit" type="submit" class="easybutton" value="Reserve now!"> </p>
</form>

我已对您的表单进行了更改,并提交了按钮。请尝试上面的代码。

答案 1 :(得分:0)

php只需要&#34; name&#34;不是&#34; id&#34;

so echo&#34; $ _ POST [&#39; from&#39;]&#34;获得&#34; easy-widget-datepicker-from&#34;的价值