【问题标题】:Use a submit <button> instead of <input> button使用提交 <button> 而不是 <input> 按钮
【发布时间】:2014-01-22 00:49:47
【问题描述】:

我想用&lt;button&gt; 而不是&lt;input&gt; 提交表单。 我知道 &lt;button&gt; 不能像提交 &lt;input&gt; 那样处理表单,我必须使用 onclick 方法。

我尝试了几件事,但它不起作用

<button name="<?php echo $name; ?>" onclick="document.<?php echo $this->action; ?>.submit()"> ... ( Action URL of the form )
<button name="<?php echo $name; ?>" onclick="document.iso<?php echo rand(); ?>.submit()">... ( name of the form )
<button name="<?php echo $name; ?>" onclick="window.location.href='<?php echo $this->action; ?>'">... ( Action url of the form )

有人知道答案吗?

【问题讨论】:

  • 生成的表单名称是什么?
  • 您想在 Click 事件中提交表单?
  • “我知道
  • -This- 可能有用
  • 表单内的按钮可以在没有任何onclick事件的情况下提交表单

标签: javascript php jquery html forms


【解决方案1】:

你可以使用buttontype="submit"like属性

<button type="submit" name="<?php echo $name; ?>">Submit</button>

【讨论】:

  • submit 是按钮元素的默认类型,您可以完全省略该属性。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-10
  • 2012-03-30
  • 1970-01-01
  • 2013-01-03
  • 2020-11-13
  • 2016-11-19
相关资源
最近更新 更多