作者mlev (大地彩妝果園)
看板Web_Design
標題[問題] javascript 取得變數?
時間Mon May 2 23:07:24 2016
<html>
<head>
</head>
<body>
<form name="number">
您要看那一集呢?<input type="text" name="number1" size=3><p>
<input type="sumit" name="YEs"
onclick="document.location.href='
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='
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
推 ian90911: document.getElementById 05/02 23:59
※ 編輯: mlev (163.27.107.1), 05/03/2016 00:22:01
推 ccvs: google會看到有篇舊文一樣的問題~ 05/03 01:05
推 hit1205: 表單有個事件是 onsubmit 05/03 12:42
噓 biobluesheep: 沒衝突,會先執行onclick再submit 05/07 01:03
→ biobluesheep: 按錯 05/07 01:03