停止提交表单中的输入字段 [英] Stop an input field in a form from being submitted

查看:127
本文介绍了停止提交表单中的输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



事情是,我不会写一些javascript(一个greasemonkey / userscript),它会在网站上的表单中插入一些输入字段。 t希望这些输入字段以任何方式影响表单,我不希望它们在提交表单时提交,我只希望我的javascript能够访问它们的值。



有什么方法可以将一些输入字段添加到表单的中间,并且在提交表单时不提交它们?



显然理想事情是输入字段不在表单元素中,但我希望我的结果页面的布局有我插入的输入字段出现在原始表单的元素之间。



 < / p> 

; input type =textid =in-between/>

或者您可以在表单提交后在jquery中简单地删除它们:

  $(form)。submit(function(){

$(this).children('#in ')。remove();

});


I'm writing some javascript (a greasemonkey/userscript) that will insert some input fields into a form on a website.

The thing is, I don't want those input fields to affect the form in any way, I don't want them to be submitted when the form is submitted, I only want my javascript to have access to their values.

Is there some way I could add some input fields into the middle of a form and not have them submitted when the form is submitted?

Obviously the ideal thing would be for the input fields to not be in the form element, but I want the layout of my resulting page to have my inserted input fields appear between elements of the original form.

解决方案

You could insert input fields with no "name" attribute:

<input type="text" id="in-between" />

Or you could simply remove them once the form is submitted (in jquery):

$("form").submit(function() {

   $(this).children('#in-between').remove();

});

这篇关于停止提交表单中的输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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