首先從類別選項中選擇一個類別,然後再從鏈接選項中選擇一個鏈接。參閱說明框內的描述,再決定是否打開鏈接頁。 -- 類別 -- 類別一 類別二 類別三 您應先選擇一個類別。
安裝 拷貝以下腳本貼在網頁的<body>之下適當位置。 <script language="JavaScript"> <!-- var num_of_cats = 4; // 包括首個空白內容的類別總數。 var open_in_newwindow=1; // 設定 1 在新窗口打開鏈接, 0 為否。 var option_array = new Array(num_of_cats); option_array[0] = new Array("請先選擇類別。");。 option_array[1] = new Array("-- 選擇一個 --", "鏈接一", "鏈接二", "鏈接三"); option_array[2] = new Array("-- 選擇一個 --", "鏈接四", "鏈接五"); option_array[3] = new Array("-- 選擇一個 --", "鏈接六", "鏈接七"); var text_array = new Array(num_of_cats); text_array[0] = new Array("首先從類別選項中選擇一個類別,然後再從鏈接選項中選擇一個鏈接。參閱說明框內的描述,再決定是否打開鏈接頁。"); text_array[1] = new Array("這是類別一的說明。", "這是鏈接一的說明。", "這是鏈接二的說明。", "這是鏈接三的說明。"); text_array[2] = new Array("這是類別二的說明。", "這是鏈接四的說明。", "這是鏈接五的說明。"); text_array[3] = new Array("這是類別三的說明。", "這是鏈接六的說明。", "這是鏈接七的說明。"); var url_array = new Array(num_of_cats); url_array[0] = new Array("#"); url_array[1] = new Array("#", "1.html", "2.html", "3.html"); url_array[2] = new Array("#", "4.html", "5.html"); url_array[3] = new Array("#", "6.html", "7.html"); function switch_select() { for (loop = window.document.form_1.select_2.options.length-1; loop > 0; loop--) { window.document.form_1.select_2.options[loop] = null; } for (loop = 0; loop < option_array[window.document.form_1.select_1.selectedIndex].length; loop++) { window.document.form_1.select_2.options[loop] = new Option(option_array[window.document.form_1.select_1.selectedIndex][loop]); } window.document.form_1.select_2.selectedIndex = 0; } function switch_text() { window.document.form_1.textarea_1.value = text_array[window.document.form_1.select_1.selectedIndex][window.document.form_1.select_2.selectedIndex]; } function box() { if (window.document.form_1.select_2.selectedIndex == 0) { alert("您想去哪��?"); } else { if (open_in_newwindow==1) window.open(url_array[window.document.form_1.select_1.selectedIndex][window.document.form_1.select_2.selectedIndex],"_blank"); else window.location=url_array[window.document.form_1.select_1.selectedIndex][window.document.form_1.select_2.selectedIndex] } } function set_orig() { window.document.form_1.select_1.selectedIndex = 0; window.document.form_1.select_2.selectedIndex = 0; } window.onload=set_orig // --> </script> <form name="form_1" onSubmit="return false;"> <textarea WRAP="virtual" name="textarea_1" rows=4 cols=50>首先從類別選項中選擇一個類別,然後再從鏈接選項中選擇一個鏈接。參閱說明框內的描述,再決定是否打開鏈接頁。</textarea><br> <!-- 這�堛漱憒r應與上面的相同。 --> <select name="select_1" onChange="switch_select(); switch_text();"> <option>-- 類別 --</option> <option>類別一</option> <option>類別二</option> <option>類別三</option> </select> <select name="select_2" onChange="switch_text();"> <option>您應先選擇一個類別。</option> <option> </option> <option> </option> </select> <input type="submit" onClick="box();" value="去"> </form>
拷貝以下腳本貼在網頁的<body>之下適當位置。