【问题标题】:Getting datepicker input values in php在 php 中获取 datepicker 输入值
【发布时间】:2017-01-03 06:06:49
【问题描述】:

我正在尝试获取 php 中的字段值,但我似乎无法获取它们。尝试了post和get,没有结果。我知道这应该是一个简单的解决方案,但我看不到错误。任何帮助表示赞赏。谢谢!

这是我的报告.html:

<HTML>
 <HEAD>
  <meta charset="utf-8">
  <link rel="stylesheet" href="css/style2.css">
  <TITLE>SAE Report</TITLE>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $(function() {
     $(".datepicker").datepicker({dateFormat:'yy-mm-dd'});
   });
  </script>

</HEAD>
<BODY>
<center>
<h1>SAE Report</h1>
</center>
 <form action = "report.php" method = "get">
 <label>Report Type</label>
    <select id="report">
        <option value="none"></option>
        <option value="new">New SAEs Report</option>
        <option value="cumulative">Cumulative SAE Report</option>
    </select>
 <label>Start Date</label><input type="text" class="datepicker" id='start' >
 <label>End Date</label><input type="text" class="datepicker" id='end'>
 <input type="submit" value="Submit" id ="submit">
 </form>
</BODY>

这是我的report.php:

<?php

$report=$_GET['report'];
   if ($report=="new"){
     $start=$_GET['start'];
     $end=$_GET['end'];
     echo 'Start date is:'.$start.' and end date is: '.$end;
   }
    else if ($report=="cumulative"){
     echo "print all SAEs";
   }    

?>

【问题讨论】:

    标签: javascript php html datepicker get


    【解决方案1】:

    您在 HTML 中缺少 name 属性。只需添加它:

    <form action = "report.php" method = "get">
        <label>Report Type</label>
        <select id="report" name="report">
            <option value="none"></option>
            <option value="new">New SAEs Report</option>
            <option value="cumulative">Cumulative SAE Report</option>
        </select>
        <label>Start Date</label><input type="text" name="start" class="datepicker" id='start' >
        <label>End Date</label><input type="text" name="end" class="datepicker" id='end'>
        <input type="submit" value="Submit" id ="submit">
    </form>
    

    【讨论】:

      猜你喜欢
      • 2018-04-19
      • 1970-01-01
      • 2016-06-11
      • 1970-01-01
      • 2016-07-05
      • 2014-06-19
      • 1970-01-01
      • 1970-01-01
      • 2016-11-02
      相关资源
      最近更新 更多