[問題] javascript 取得變數?

看板Web_Design作者 (大地彩妝果園)時間9年前 (2016/05/02 23:07), 9年前編輯推噓2(311)
留言5則, 4人參與, 最新討論串1/1
<html> <head> </head> <body> <form name="number"> 您要看那一集呢?<input type="text" name="number1" size=3><p> <input type="sumit" name="YEs" onclick="document.location.href='" rel="nofollow">http://www.kimo.com.tw/xxx.pdf'"> </form> </body> </html> 請問要怎麼把集數帶到xxx.pdf 讓使用者按下Yes時 網頁會自動跑到指定的集數檔呢? 有查到 document.number.number1.value 很像可以取得表單裡文字的值 但…沒用 -------- <html> <head> </head> <body> <form name="number"> 您要看那一集呢?<input id="num" type="text" name="number1" size=3><p> <input type="sumit" value="yes" onclick="document.location.href='" rel="nofollow">http://www.edu.tw/aaaa'+document.getElementById('num').value+'.pdf'"> </form> </body> </html> -- 很奇怪的誤打誤撞解決了 正確的語法應該是<input type="submit" 但我打成sumit卻跑出我要的結果 而打正確的submit時 卻沒反應 不知是不是submit和onclick不能同時用 那我是不是要改成什麼onmouseXXX的 就是當滑鼠碰到"送出"的按鈕時 就自動轉址 這樣就不會有submit和onclick衝突的情況了? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.27.107.1 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1462201646.A.E7E.html

05/02 23:59, , 1F
document.getElementById
05/02 23:59, 1F
※ 編輯: mlev (163.27.107.1), 05/03/2016 00:22:01

05/03 01:05, , 2F
google會看到有篇舊文一樣的問題~
05/03 01:05, 2F

05/03 12:42, , 3F
表單有個事件是 onsubmit
05/03 12:42, 3F

05/07 01:03, , 4F
沒衝突,會先執行onclick再submit
05/07 01:03, 4F

05/07 01:03, , 5F
按錯
05/07 01:03, 5F
文章代碼(AID): #1N9sqkv- (Web_Design)
文章代碼(AID): #1N9sqkv- (Web_Design)