2013-06-25 328 views
-2

我有我想要的用戶能夠使用形式輸入按鍵提交或點擊提交按鈕

回車鍵或點擊按鈕提交表單。

這裏是我的代碼:

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

感謝您的幫助。

+0

你能不能谷歌的HTML表單提交 – user568109

+0

我可能會建議把什麼不工作的一些詳細信息。例如,在這種情況下,我想象你沒有一個按鈕可以點擊。 – jhoyla

回答

1

您的表單需要一個提交按鈕...因此請在您的表單中添加<input type="submit" value="Submit"/>

你應該看看these articles on HTML Forms ......

+0

謝謝,但這並沒有激活形式「SetSrc()」上按回車鍵 – mewebs

+0

@jhoyla如果你看看代碼,是按鈕。我試圖切換到按鈕,它不起作用。 – mewebs

+0

@ user2518599然後將'onclick =「SetSrc()」'添加到提交按鈕。 –