【问题标题】:Getting variables from a form which uses a div instead of input从使用 div 而不是输入的表单中获取变量
【发布时间】:2017-07-06 00:10:03
【问题描述】:

这是我的表格:

<form method="POST" action="configuration/raportare/generate_crangasi.php">
<div id="reportrange" name="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%">
<i class="glyphicon glyphicon-calendar fa fa-calendar">
</i>&nbsp;<span></span> 
<b class="caret"></b>
</div><br>
<button type="submit">Generează raport</button>
</form>

这是 generate_orhideea.php 文件:

//SOME CODE HERE
require_once "../../configuration/db.php";
$begin = $_POST['reportrange'];
$rows = mysqli_query($connection, "SELECT * FROM clienti_orhideea WHERE data_inregistrare >= '$begin'");
//SOME CODE HERE

我收到错误:

未定义的变量报告范围

我该如何解决这个问题?

【问题讨论】:

  • 不。必须是输入字段。
  • 你是对的。我改变了整个代码。谢谢!
  • 您应该更改您的问题或将修改后的代码添加到答案中:)
  • 我做到了。谢谢。

标签: html forms variables button post


【解决方案1】:

我将代码更改为:

<form method="POST" action="configuration/raportare/generate_crangasi.php">
<input type="text" name="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc; width: 100%"/><br>
<input type="submit" value="Generează raport">
</form>

我想对一些 javascript 代码使用 &lt;div&gt; 和 &lt;button&gt;,但我对其进行了调整以使用输入 type="submit"。我也消除了

 <i class="glyphicon glyphicon-calendar fa fa-calendar">
    </i>&nbsp;<span></span> 
    <b class="caret"></b>

不再适用于输入的代码。 (我在 css 中制作了这个字形)。

【讨论】:

  • 你想让 PHP 记录那个字形吗?有一种方法可以做到这一点。
  • 如何在输入中集成该字形图标?没有 css? :D
  • 把整个东西变成一个php变量。但请问,让某人在表单中只提交一个图标的目的是什么?
  • 图标只是为了纯粹的设计。
  • 那么它不是表单提交的一部分吗?不过,如果你把类变成一个字符串,这是可能的。
猜你喜欢
  • 1970-01-01
  • 2014-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多