酷!學園
2010-09-03 13:23 *
歡迎光臨, 訪客. 請先 登入註冊一個帳號.
您忘了 啟用您的帳號嗎?

請輸入帳號, 密碼以及預計登入時間
新聞:
 
   首頁 | Study-Area | 鳥園 | 鳥哥的Linux私房菜   說明 搜尋 日曆 登入 註冊  
頁: [1]
  列印  
作者 主題: [已解決]請問用radio選擇前往該網站該如何製作呢  (閱讀 1913 次)
0 會員 以及 1 訪客 正在閱讀本篇主題.
hayaman212
活潑的大學生
***
文章: 362


檢視個人資料
« 於: 2010-02-05 18:10 »

程式碼:
<table width="200" border="1">
  <tr>
    <td><label>
      <input type="radio" name="radio" id="radio" value="http://tw.yahoo.com" />
    A網站</label></td>
  </tr>
  <tr>
    <td><input type="radio" name="radio" id="radio2" value="http://www.google.com" />
      B網站</td>
  </tr>
  <tr>
    <td><input type="radio" name="radio" id="radio3" value="http://www.facebook.com" />
      C網站</td>
  </tr>
  <tr>
    <td><label>
      <input type="submit" name="button" id="button" value="前往" />
    </label></td>
  </tr>
</table>
« 最後編輯時間: 2010-04-23 12:20 由 hayaman212 » 已記錄

slime
俺是博士!
*****
文章: 1514


檢視個人資料
« 回覆文章 #1 於: 2010-02-05 18:47 »

把 form 指向一個 JavaScript 的 function , 由 function 做切換網址的動作?
已記錄

冷笑話: 我的 IP 是 127.0.0.1
Error404
可愛的小學生
*
文章: 29



檢視個人資料
« 回覆文章 #2 於: 2010-04-17 21:30 »

程式碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
function go(targ) {
    for(i=0;i<document.form1.radio.length;i++){
        if(document.form1.radio[i].checked){
            eval(targ+".location='"+document.form1.radio[i].value+"'");
        }
    }
}
//]]>
</script>
<form id="form1" name="form1" method="post" action="">
  <label>
  <input type="radio" name="radio" value="http://tw.yahoo.com" />
  </label>
  Yahoo<br />
  <label>
  <input type="radio" name="radio" value="http://google.com" />
  </label>
  Google
  <br />
  <label>
  <input type="radio" name="radio" value="http://www.facebook.com" />
  </label>
  Facebook<br />
  <label>
  <input type="button" name="Go" id="Go" value="前往" onclick="go('parent');"/>
  </label>
  <br />
</form>
</body>
</html>
« 最後編輯時間: 2010-04-17 21:41 由 Error404 » 已記錄
hayaman212
活潑的大學生
***
文章: 362


檢視個人資料
« 回覆文章 #3 於: 2010-04-23 12:19 »

Error404 大大
出現新的高手?!
謝謝
已記錄

頁: [1]
  列印  
 
前往:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
本頁花了 0.042 秒,以及 17 次的資料庫查詢。