首先从类别选项中选择一个类别,然後再从链接选项中选择一个链接。参阅说明框内的描述,再决定是否打开链接页。 -- 类别 -- 类别一 类别二 类别三 您应先选择一个类别。
安装 拷贝以下脚本贴在网页的<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> <!-- 这里的文字应与上面的相同。 --> <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>之下适当位置。