按下输入键提交表单或点击提交按钮 [英] form submit with enter key pressed or click submit button

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

问题描述

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

Enter键或点击按钮提交。



以下是我的代码:

 < html> 
< head>
< link href =style.css =stylesheettype =text / css/>
< title> Blah< / title>
< script type =text / javascript>
函数SetSrc()
{
document.getElementById(myIfreme1)。src ='http://'+
document.getElementById(txtSRC).value;
}
< / script>
< / head>
< body>
< form>
输入网址:http://
< input type =textid =txtSRC/>
< input type =buttonvalue =GOonclick =SetSrc()/>
< / form>
< div style =clear:both> 320 width< / div>
< iframe id =myIfreme1src =frameborder =0marginwidth =0height =480width =320
scrolling =yes><的iframe>
< / body>
< / html>

感谢您的帮助。

解决方案

您的表单需要一个提交按钮...因此,请添加< input type =submitvalue =Submit/> 里面您的表单。



您应该查看这些HTML表单上的文章 ...


I have a form that I want the user the be able to use the

Enter key or Click on the button to submit it.

Here is the code I have:

<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>

Thanks for your help.

解决方案

Your form needs a submit button... so add <input type="submit" value="Submit"/> inside your form.

You should check out these articles on HTML Forms...

这篇关于按下输入键提交表单或点击提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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