下拉式選單2
將下列程式碼複製至<head>程式碼</head>區內。
<script language="JavaScript" type="text/javascript"> document.write('<form name="selecter1"><select name="select1" size=1>'); document.write('<option value=none>搜尋引擎'); document.write('<option value="http://dob.tnc.edu.tw/authorHD/44/H1-001.htm">示範頁'); document.write('<option value=none>--------------------'); document.write('<option value="http://www.kimo.com.tw">雅虎奇摩站'); document.write('<option value="http://www.sina.com.tw">SINA新浪網'); document.write('<option value="http://www.pchome.com">PChome'); document.write('<option value="http://www.hinet.net">HINET'); document.write('<option value="http://www.yam.com.tw">蕃薯藤'); document.write('<option value=none>--------------------'); document.write('</select>'); document.write('<input type="button" value="Go" onclick="go1()">'); document.write('</form>'); </script> |
將下列程式碼複製至<body>程式碼</body>之間。
<script language="JavaScript" type="text/javascript"> // original code by Bill Trefzger 12/12/96 function go1(){ if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") { location = document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value}} </script> |