使用< form>外的按钮提交表单标签 [英] Submit form using a button outside the <form> tag

查看:91
本文介绍了使用< form>外的按钮提交表单标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有:

 < form method =getaction =something.php> 
< input type =textname =name/>
< / form>

< input type =submit/>

如何在窗体外使用提交按钮提交表单,我认为在HTML5中theres为提交的动作属性,但我不确定这是否完全跨浏览器,如果它不是有反正这样做?

解决方案



以下是规范说明


用于创建控件的元素通常出现在FORM
元素中,但也可能出现在FORM元素声明
之外接口。这在内部事件的
部分进行了讨论。 请注意,表单外的控件不能成功控制


这就是我的大胆



提交按钮被视为控件。



http://www.w3 .org / TR / html4 / interact / forms.html#h-17.2.1

来自评论


我有一个多选项卡设置区域,其中包含一个按钮,用于更新所有设计区域,由于
的设计,按钮将位于表单之外。


为什么不在表单中放置 input ,而是使用CSS将它放在页面的其他位置?


Say I have:

<form method="get" action="something.php">
    <input type="text" name="name" />
</form>

<input type="submit" />

How do I go about submitting that form with that submit button outside of the form, I think in HTML5 theres an action attribute for the submit but I'm not sure if thats fully cross-browser and if it isn't is there anyway to do this?

解决方案

As far as I know, you cannot do this without javascript.

Here's what the spec says

The elements used to create controls generally appear inside a FORM element, but may also appear outside of a FORM element declaration when they are used to build user interfaces. This is discussed in the section on intrinsic events. Note that controls outside a form cannot be successful controls.

That's my bold

A submit button is considered a control.

http://www.w3.org/TR/html4/interact/forms.html#h-17.2.1

From the comments

I have a multi tabbed settings area with a button to update all, due to the design of it the button would be outside of the form.

Why not place the input inside the form, but use CSS to position it elsewhere on the page?

这篇关于使用&lt; form&gt;外的按钮提交表单标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆