【问题标题】:How to add date inside the <td> tag?如何在 <td> 标签内添加日期?
【发布时间】:2019-02-15 15:30:41
【问题描述】:

我的表单上有这个输入框:

&lt;td contenteditable="true" class="date"&gt;&lt;/td&gt;

我正在尝试向其中添加日期下拉列表,所以我所做的是:

&lt;td contenteditable="true" class="date"&gt;&lt;input type="date"&gt;&lt;/td&gt;

现在当我点击发送时,它不会保存到数据库中。有没有其他方法可以做到这一点?

以下是完整代码,以备不时之需:

<table class="table table-bordered" style="border-radius: 10px;" id="crud_table">
     <tr>
      <th width="30%">Requested By</th>
      <th width="10%">Start Date</th>
      <th width="10%">Employee Name</th>
      <th width="10%">Position</th>
      <th width="10%">Account</th>
      <th width="10%">Platform</th>
      <th width="45%">Processor</th>
      <th width="10%">RAM</th>
      <th width="10%">Monitor</th>
      <th width="10%">Phone</th>
      <th width="10%">Phone Type</th>
      <th width="10%">Headset</th>
     </tr>
     <tr>
      <td contenteditable="true" class="reqname" required></td>
      <td contenteditable="true" class="date"><input type="date"></td>
      <td contenteditable="true" class="empname"></td>
      <td contenteditable="true" class="position"></td>
      <td contenteditable="true" class="account"></td>
      <td contenteditable="true" class="platform"></td>
      <td contenteditable="true" class="processor"></td>
      <td contenteditable="true" class="ram"></td>
      <td contenteditable="true" class="monitor"></td>
      <td contenteditable="true" class="phone"></td>
      <td contenteditable="true" class="phonetype"></td>
      <td contenteditable="true" class="headset"></td>
     </tr>
    </table>

PS:当我点击发送时我得到All fields are required,这意味着我没有从日期下拉列表中获得任何值。

【问题讨论】:

  • 您并没有真正为我们提供太多帮助。
  • @JCode 你是什么意思?你需要知道的一切都在那里,哈哈。
  • @JCode 可能提到的一些事情:问题标记为 PHP 和 MySQL,但问题中根本没有 PHP 代码或 SQL。您说“当我点击发送时”,但您发布的 HTML 中没有说明数据将如何发送到 PHP。是否涉及一些JS?桌子周围有表格吗?
  • @Don'tPanic 是的,他还说他正在“发送”数据,但他的代码中没有表格。
  • @JCode 我想id="crud_table" 可能意味着有某种 JS 库可以让表格像表格一样,但我只是猜测。

标签: php html mysql database phpmyadmin


【解决方案1】:

&lt;input type='date'&gt; 添加名称属性。为了在提交表单(POST 或 GET)时将元素作为参数发送,它必须具有有效的名称属性。

<input type="date" name="custom_date">

【讨论】:

    【解决方案2】:

    输入类型“日期”包括年、月、日,但不包括时间。

    <input type="date" name="custom_date" class="date">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 1970-01-01
      • 2012-09-09
      • 1970-01-01
      • 2016-11-13
      • 2017-11-05
      相关资源
      最近更新 更多