인터넷정보

다중 셀렉트(select) 박스 2

알 수 없는 사용자 2007. 10. 18. 13:41
  1. <style type=text/css>
  2. select {font-size:9pt;font-family:굴림;}
  3. </style>
  4. </head>
  5. <body bgcolor=white text=black link=blue vlink=purple alink=red>
  6. <table align=center>
  7. <form name=form method=POST action="">
  8. <tr>
  9. <td>
  10. <select name="high_cg" size="1" onchange="changeCG(document.form.high_cg)"></select>
  11. <select name="mid_cg" size="1">
  12. <option value="중분류">중분류</option>
  13. </select>
  14. </td>
  15. </form>
  16. <script language="JavaScript">
  17. <!-- JavaScript
  18. midCG = new Array(20);
  19. midCG[0] = "";
  20. midCG[1] = new Array("TV","라디오","인터넷방송","신문","웹진","잡지","각종 통계","쿨사이트");
  21. midCG[2] = new Array("영화","연극/음악","만화-애니메이션","문학","연예","유머-재미","게임");
  22. midCG[3] = new Array("공연예술","공예","디자인","박물관,화랑","예술가"," 전통예술");
  23. midCG[4] = new Array("정부기관","정치","법","군대","대사관","시민단체");
  24. midCG[5] = new Array("사람들","사회이슈","문화","기관-단체","환경-자연","식음료","동호회");
  25. midCG[6] = new Array("회사","광고","투자-재테크","금융","증권","보험","부동산","취업-채용","창업");
  26. midCG[7] = new Array("쇼핑몰"," 경매","공동구매 ","가격비교","소비자평가");
  27. midCG[8] = new Array("무료정보","무료다운","이벤트-경품 소개");
  28. midCG[9] = new Array("하드웨어","소프트웨어","프로그래밍 언어","멀티미디어","게임","보안과 암호","인터넷종합","채팅","통신-네트워크","OS");
  29. midCG[10] = new Array("패션","미용","가족","결혼","육아","다이어트","인테리어");
  30. midCG[11] = new Array("여행-관광","취미","레저","자동차","게임");
  31. midCG[12] = new Array("실내스포츠","실외스포츠","스포츠스타","스포츠관련 미디어","스포츠종합");
  32. midCG[13] = new Array("인문과학","사회과학","자연과학","공학");
  33. midCG[14] = new Array("건강일반","병원","의학정보","한의학","의료상담","다이어트");
  34. midCG[15] = new Array("교육일반","학교","선생님","기관-단체","온라인교육","시험-자격증");
  35. midCG[16] = new Array("유학","도서관","전문가서비스");
  36. midCG[17] = new Array("학과","동아리","학생회","동문-동창회","연구소","소모임");
  37. midCG[17] = new Array("기독교","천주교","불교","민족종교","기타");
  38. midCG[18] = new Array("가수","탤런트","개그맨","영화배우","모델","스포츠스타","순수예술인");
  39. midCG[19] = new Array("기업","사람","기타");
  40. listHighCG = new Array("대분류 선택","뉴스-미디어","엔터테이먼트","예술","정치 및 법","사회문화","경제","쇼핑","공짜&무료","컴퓨터,인터넷","가정-여성","레크리에이션","스포츠","학문-과학","건강-의학","교육","학교","종교","팬클럽","안티사이트");
  41. highSelect = document.form.high_cg;
  42. midSelect = document.form.mid_cg;
  43. function strPos(s, s1)
  44. {
  45. if(s1 == null) return;
  46. for(i=0; i<s.length; i++)
  47. {
  48. if(s[i] == s1) return i;
  49. }
  50. return -1;
  51. }
  52. function setMidCG(high_cg,mid_cg)
  53. {
  54. var num = midSelect.length;
  55. for(i=0; i<num; i++)
  56. {
  57. midSelect.options[1]= null;
  58. }
  59. midSelect.options[0] = new Option("중분류 선택","");
  60. for(var i=0; i<midCG[high_cg].length; i++)
  61. {
  62. var myitem = new Option(midCG[high_cg][i])
  63. midSelect.options[i+1] = myitem;
  64. }
  65. if(mid_cg > 0)
  66. {
  67. midSelect.options.selectedIndex = mid_cg;
  68. }
  69. }
  70. function changeCG(menu)
  71. {
  72. selectNum = menu.selectedIndex;
  73. setMidCG(selectNum,0);
  74. }
  75. function init()
  76. {
  77. for(var i=0; i<listHighCG.length; i++)
  78. {
  79. var item = new Option(listHighCG[i])
  80. highSelect.options[i] = item;
  81. }
  82. pos = strPos(listHighCG,"컴퓨터,인터넷");
  83. if(pos < 1) pos = 0;
  84. setMidCG(pos,strPos(midCG[pos],"인터넷종합")+1);
  85. highSelect.options.selectedIndex = pos;
  86. }
  87. window.onload = init;
  88. // - JavaScript - -->
  89. </script>
  90. </tr>
  91. </table>
반응형