Amber unlimited linkage menu-JavaScript Edition
<Html> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"> <meta content = "Amber [hopesoft], http://www.51ajaxcom "Name =" author "> <title> net-javascript unlimited linkage menu </title> <style type =" text/css "> body, td {font-family:; font-size: 12px ;}</style> <script language = "javascript">/* required * \ | Subject: JavaScript three-level linkage menu | Version: 1.0 | Author: amber [hopesoft] | FileName: HPMenu. js | Created: 2005-10-16 | LastModified: 2005-10-16 | Download: http://www.10090.com/Demo/ Hpmenu/HPMenu.rar | Explain: http://www.10090.com/Demo/ | Demo: http://www.10090.com/Demo/ | ----------------------------------------------------------------------------- | MSN: hopesoft at msn.com http://www.51ajax.com/bbs/ | Copyright (c) 2004-2005 HopeSoftStudio | \ * platform */function Menu (theform, menuid) {/* platform * \ * 1. variable definition */* optional * // define menu level MenuClass, menu length array MenuLenArr, // menu name array MenuArr, lower menu array SubMenuArr, menu ID array MenuIdArr var MenuClass, menuLenArr, MenuArr, SubMenuArr, MenuIdArr // defines the separator: splitchar1, splitchar2 var splitchar1, splitchar2 // defines the temporary array, sub-array, array length, var arr, subarr, arrlen/* --------------------------------------------------------------------------- * \ * 2. variable assignment */* locale */MenuArr = new Array () MenuLenArr = new Array () SubMenuArr = new Array () MenuIdArr = new Array () menuArr [1] = "Europe | Asia | Africa | Oceania | North America | south america" // continent name |... menuArr [2] = "Europe ### Germany | Europe ### France | North America ### United States ||| North America ### Canada || Asia # # China | Africa ### Egypt | Oceania ### Australia | South America ### Mexico "// continent name ### country name |. .. menuArr [3] = "China ### Beijing | China ### Shanghai | United States ### Washington ||| United States ### New York ||| Germany # # Berlin | France ### paris | Canada ### Toronto | Egypt ### Cairo | Australia ### Sydney | Mexico # # Mexico City "// country name ### city name |... menuArr [4] = "Beijing ### Chaoyang District | Shanghai ### Xuhui District | Guangzhou ### Tianhe District | New York ### Manhattan District | Washington # # Washington region | Berlin ### sinbury region | Paris ### greater Paris region | Cairo ### Greater Cairo ||| Sydney ### Sydney region | | Mexico City ### Mexico City "// country name ### city name |... menuIdArr [1] = "zhou" MenuIdArr [2] = "guo" MenuIdArr [3] = "shi" MenuIdArr [4] = "qu" MenuClass = 4 // Level 4 menu splitchar1 = "| "; splitchar2 = "###";/* ------------------------------------------------------------------------- * \ * 3. generate an array */* struct */for (iii = 1; iii <= MenuClass; iii ++) {arr = MenuArr [iii]. split (splitchar1); len = arr. length; subarr = new Array () for (I = 0; I <len; I ++) {subarr [I] = arr [I]. split (splitchar2);} len = subarr. length; subMenuArr [iii] = subarr MenuLenArr [iii] = len} // =============== change the context menu ========== ============== var self, submenu, thislen, thisarr // self current menu // submenu // theform: the form object [type: object] // menuid: current menu level ID, for example, the level 1 menu is 1 self = eval ("document. "+ theform. name + ". "+ MenuIdArr [menuid]) submenu = eval (" document. "+ theform. name + ". "+ MenuIdArr [menuid + 1]) thislen = MenuLenArr [menuid + 1] thisarr = SubMenuArr [menuid + 1] submenu. length = 0 submenu. options. add (new Option ("----- select -----", ""); for (I = 0; I <thislen; I ++) {if (thisarr [I] [0] = self. value) {submenu. options. add (new Option (thisarr [I] [1], thisarr [I] [1]) ;}} submenu. options [0]. selected = true // ============== change the lower-level menu ==================== var kkk for (kkk = menuid + 2; kkk <= MenuClass; kkk ++) {submenu = eval ("document. "+ theform. name + ". "+ MenuIdArr [kkk]) submenu. length = 0 submenu. options. add (new Option ("----- select -----", ""); submenu. options [0]. selected = true} script </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]