【问题标题】:form submit with enter key pressed or click submit button [closed]按下回车键提交表单或单击提交按钮[关闭]
【发布时间】:2013-06-22 08:19:25
【问题描述】:

我有一个表单,我希望用户能够使用

输入键或点击按钮提交。

这是我的代码:

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Blah</title>
<script type="text/javascript">
function SetSrc()
{
document.getElementById("myIfreme1").src = 'http://' +   
document.getElementById("txtSRC").value;
}
</script>
</head>
<body>
<form>
Enter URL:  http://
<input type="text" id="txtSRC" />
<input type="button" value="GO" onclick="SetSrc()" />
</form>
<div style="clear:both">320 width</div>
<iframe id="myIfreme1" src="" frameborder="0" marginwidth="0" height="480" width="320" 
scrolling="yes"></iframe>
</body>
</html>

感谢您的帮助。

【问题讨论】:

  • 你能不能不google HTML表单提交
  • 我可以建议提供更多关于什么不起作用的信息。例如,在这种情况下,我想您根本没有可以点击的按钮。

标签: javascript html forms submit


【解决方案1】:

您的表单需要一个提交按钮...所以在您的表单中添加&lt;input type="submit" value="Submit"/&gt;

您应该查看these articles on HTML Forms...

【讨论】:

  • 谢谢,但按下回车键时不会激活表单“SetSrc()”
  • @jhoyla 如果查看代码, 就是按钮。我尝试将其切换为按钮,但它不起作用。
  • @user2518599 然后将onclick="SetSrc()" 添加到提交按钮。
  • 我将输入切换为: 效果相同,按 Enter 键什么都没有。
  • @user2518599 type="submit"
猜你喜欢
  • 2017-12-28
  • 1970-01-01
  • 1970-01-01
  • 2012-01-02
  • 2018-02-10
  • 1970-01-01
  • 2017-05-16
  • 1970-01-01
相关资源
最近更新 更多