JavaScript 在字段值更改后自动提交表单,无需用户点击?
我有一个带有一些字段和一个提交按钮的网络表单。我有一个函数每秒检查一个文件并输出值。有一个字段导入该值并显示它。
我需要的是,一旦该字段的值发生更改,应自动单击提交按钮。
对于某些代码:
我的表单名称是 form1
,这是输入字段:
<input name="code" id="code" type="text" size="64" maxlength="128" onchange="send_data();" />
这是我的 JavaScript 函数:
<SCRIPT LANGUAGE="javascript">
function send_data()
{document.form1.submit();}
</SCRIPT>
如果我自己在字段中输入任何内容并在其外部单击,则表单将被提交自动地。但如果该值自动更改,则不会发生任何事情...
Javascript 是否有可能做到这一点?
I have a web form with some fields and a submit button. I have a function that checks a file every second and outputs the value. One field imports this value and displays it.
What I need is as soon as the value on this field is changed, the submit button should be automatically clicked.
For some code:
My form name is form1
, Here is the input field:
<input name="code" id="code" type="text" size="64" maxlength="128" onchange="send_data();" />
Here is the JavaScript function I have:
<SCRIPT LANGUAGE="javascript">
function send_data()
{document.form1.submit();}
</SCRIPT>
If I myself type in anything in the field and click outside it, The form will be submitted automatically. But if the value is changed automatically, nothing will happen...
Is there a possibility in Javascript to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你可以将旧值与新值进行比较。
I am guessing you could just compare the old value with the new one.