html输入字段OUTSIDE的形式 [英] html input field OUTSIDE of form

查看:147
本文介绍了html输入字段OUTSIDE的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组包含输入的表单,并且希望在其中一个更改时刷新页面。我在页面的OTHER侧有第二组输入,而且CSS布局并不便于我将它们放在同一个< form> < / form> 标记。我想知道是否有一种方法可以确保位于< form> 标签之外的那些输入仍然与该表单关联。有什么方法可以给输入分配一个表单ID?

任何帮助都将非常感谢。



感谢!

解决方案

在HTML5中,您可以使用 form 属性


默认情况下,表单关联元素与其祖先表单元素相关联,但可能有如果一个form-associated元素具有指定的form属性,那么该属性的值必须是该元素的form元素的ID


示例:

 < form id =myform> 
< input id =somethingtype =text>
< / form>

< button form =myformtype =submit>在那里提交表单< / button>

然而,您应该确保用户清楚这些视觉上分离的表单元素是事实上的连接。


I have a form with a set of inputs, and I want my page to refresh when one of them changes. I have a second set of inputs on the OTHER side of the page, and the css layout doesn't make it convenient for me to put them in the same <form> </form> tag. I was wondering if there is a way that I can make sure those "inputs" that are located outside the <form> tag are still associated with that form. Is there some way we can assign a "form id" to the inputs?

Any help would be much appreciated.

Thanks!

解决方案

In HTML5, you can use the form attribute:

A form-associated element is, by default, associated with its ancestor form element, but may have a form attribute specified to override this.

If a form-associated element has a form attribute specified, then that attribute's value must be the ID of a form element in the element's owner Document.

Example:

<form id="myform">
    <input id="something" type="text">
</form>

<button form="myform" type="submit">Submit that form over there</button>

You should however make sure that it is clear to the user that these visually separated form elements are in fact connected.

这篇关于html输入字段OUTSIDE的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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