[問題] 關於表單和按鈕

看板Web_Design作者 (若葉)時間19年前 (2006/10/29 17:50), 編輯推噓3(302)
留言5則, 3人參與, 最新討論串1/2 (看更多)
http://blackyoh.hp.infoseek.co.jp/cgi-bin/board1/patio.cgi?mode=view&no=424 function GoToURL(j) { var URLis; URLis = document.URLframe.Dest.value; var location = ("patio.cgi?mode=view&no=" + URLis); this.location.href = location;} <form name="URLframe"> <input type="text" name="Dest" size="3" value="1" maxlength="3"> <input type="button" name="View" value="GO" onclick="GoToURL(this)"> </form> 因為有需要,所以做了一個簡短的語法 在「文字方塊」裡,輸入數字後,用滑鼠按下按鈕,可以正常顯示(如網址A)                按下鍵盤「ENTER」時,卻直接回到主頁(如網址B) A http://blackyoh.hp.infoseek.co.jp/cgi-bin/board1/patio.cgi?mode=view&no=424http://blackyoh.hp.infoseek.co.jp/cgi-bin/board1/patio.cgi?Dest=424 可以請教一下,該如何解決呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.170.10.176

10/29 18:01, , 1F
button的 onclick 改為 onsubmit看看
10/29 18:01, 1F

10/29 18:05, , 2F
試過後不行,而且連按鈕都沒反應了
10/29 18:05, 2F
※ 編輯: roya123456 來自: 218.170.10.176 (10/29 18:09)

10/30 09:16, , 3F
你是指游標還停在文字輸入時就按下enter卻不會換頁嗎
10/30 09:16, 3F

10/30 12:44, , 4F
<input type="text" onKeyPress="checkEnter(event)">
10/30 12:44, 4F

10/30 12:44, , 5F
再寫function checkEnter(event)的內容,判斷按下enter..
10/30 12:44, 5F
文章代碼(AID): #15H7bOGe (Web_Design)
文章代碼(AID): #15H7bOGe (Web_Design)