如何通过表单POST方法传递jquery datepicker值? [英] How to pass the jquery datepicker value in form POST method?
问题描述
我有一个日期格式的输入文本,并且我使用JQuery datepicker选择日期.
I have a input text in the form for date and i use JQuery datepicker to select date.
<input type="text" id="datepicker" name="datepicker" value="Date"/>
当我使用表单发布将值发布到另一个php中进行计算时.我不能仅从此输入文本中获取值.我得到的是空值,而不是选定的日期.
when i use form post to post the values into another php for calculation. i don't get the values from this input text alone. i get an empty value instead of selected date.
$date=$_POST['datepicker'];
我不确定如何以POST形式传递datepicker值.有人可以帮我吗?
i'm not sure of how to pass the datepicker value in form POST. Can someone help me out?
推荐答案
jQuery的日期选择器与发布表单无关.如果您将表单设置为发布",则用户选择日期后在该输入字段中留下的所有内容都将随该表单一起发送.
jQuery's datepicker has nothing to do with posting your form. If your form is set to "post" then whatever is left in that input field after the user has selected a date will be sent with the form.
<form action="process.php" method="post">
<input type="text" id="datepicker" name="datepicker" value="Date"/>
</form>
给你:
$date = $_POST['datepicker'];
但是,如果您的表单是作为获取"请求发送的,则您需要这样访问它.
However if your form is being sent as a "get" request you'll need to access it as such.
<form action="process.php" method="get">
<input type="text" id="datepicker" name="datepicker" value="Date"/>
</form>
给你:
$date = $_GET['datepicker'];
这篇关于如何通过表单POST方法传递jquery datepicker值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!