Php HTML表单未将日期传递给变量
嘿,我正在使用jquery日期选择器输入一个日期,它没有传递我选择的值。 这是表格中的代码。表单的其余部分可以工作,但此部分无效Php HTML表单未将日期传递给变量,php,jquery,Php,Jquery,嘿,我正在使用jquery日期选择器输入一个日期,它没有传递我选择的值。 这是表格中的代码。表单的其余部分可以工作,但此部分无效 <form name="htmlform" method="post" action="contact-action.php"> <table align="center" width="450px"> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smo
<form name="htmlform" method="post" action="contact-action.php">
<table align="center" width="450px">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<tr>
<td valign="top">
<label for="datepicker">Todays Date *</label>
<input type="text" name ="datepicker "id="datepicker" maxlength="50" size="30">
</td>
</tr>
这是表示这些值的代码
$today_date = $_POST['datepicker'];
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$comments = $_POST['comments'];
$age = $_POST['radio'];
echo "Thankyou for your providing </br>
Date: $today_date </br>
Name: $firstname $lastname </br>
Email: $email </br>
Telephone: $telephone </br>
Comments: $comments </br>
Age: $age</br>
An Email has been sent to the address you provided.";
我不是最擅长php的,所以放轻松点
非常感谢删除名称中的空格
name ="datepicker " to name="datepicter"
改变
到
这应该可以解决您的问题。链接和脚本这些东西应该保留在标题标记中,而不是表标记中,将它们从表标记中移除
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jqueryui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body><form name="htmlform" method="post" action="contact-action.php">
<table align="center" width="450px">
<tr>
<td valign="top">
<label for="datepicker">Todays Date *</label>
<input type="text" name ="datepicker "id="datepicker" maxlength="50" size="30">
</td>
</tr></body>
仅供参考,您的示例中有一个输入错误:id=datepickerOutput?你提交表格时得到了什么?
$('#datepicker').datepicker({
onSelect: function(dateText, inst) {
$("#datepicker").val(dateText);
}
});
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jqueryui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body><form name="htmlform" method="post" action="contact-action.php">
<table align="center" width="450px">
<tr>
<td valign="top">
<label for="datepicker">Todays Date *</label>
<input type="text" name ="datepicker "id="datepicker" maxlength="50" size="30">
</td>
</tr></body>