搜索文章:

首页  |  Java技术  |  Asp.net  |  Asp编程  |  VC/C++  |  Delphi  |  VB编程

动态创建下拉菜单

<html>
<head>

<title>动态下拉菜单</title>
<style>
select.smallsel
{
  background-color: white;
  color: #000080;
  font-size: 9pt
}
</style>
<script language=javascript>
<!-- hide from old browsers...

/*   动态下拉菜单 -- written by taylor chen (taylor999)
    如果您发现任何问题,请e-mail给我,taylor@etang.com
*/


var info = new array(
  "杂文*弥天大谎的背后|院士相当于副省级?|为教育打几个激灵|预算黑洞一例|官不贵,民不贱|省了麻烦|

轿车不如轿子说|这回确是个别|血和泪构成的笑话|给张艺谋松绑吧!",
  "生活随笔*木兰漂亮吗?|一张旧车票|酒味杂谈|时空隧道|最后捞一把",
  "文选*家庭也要有民主|“待遇”的联想|“农民”不是形容词|只多一点点",
  "读者*当代“士子”之悲|谈程序|厅长说与百姓说|其实很高明");

var infoa=new array(
  "焦点话题*安徽:国企领导可以超龄任职|新世纪怎么花钱|武汉:企业将告别行政级别",
  "读者书屋*欲火",
  "品味园*破译“中国人之谜”不妨读读《闲话中国人》|请客吃饭乐无穷|走动走动向上浮动|文人也当谋富

|做并享受着———与白岩松笑谈摭拾|比谁写得厚",
  "环球采风*法国建成绿色学校|俄罗斯第一夫人温情谈恋史|法国人才外流有原因|德国电脑人才可破例|德

国慕尼黑啤酒节",
  "人物春秋*我所知道的胡乔木|自信些,迎接全球化|红与黑");
var mywork= new array("",info,infoa);
/*********************************************************************

******/

function stringsplit ( string, delimiter ) {
  if ( string == null || string == "" ) {
    return null;
  } else if ( string.split != null ) {
    return string.split ( delimiter );
  } else {
    var ar = new array();
    var i = 0;
    var start = 0;
    while( start >= 0 && start < string.length ) {
       var end = string.indexof ( delimiter, start ) ;
       if( end >= 0 ) {
         ar[i++] = string.substring ( start, end );
         start = end+1;
       } else {
         ar[i++] = string.substring ( start, string.length );
         start = -1;
       }
    }
    return ar;
  }
}
/****************************************************

******/
var menu1 = new array();
var menu2 = new array();
/*********************************************************

******/
function createmenus ( wh ) {
  var infoname = new array();
  infoname=mywork[wh];
  for ( var i=0; i < infoname.length; i++ ) {
    menu1[i] = stringsplit ( infoname[i], * );
    menu2[i] = stringsplit ( menu1[i][1], | );
  }

  var author = document.myform.main;
  var book = document.myform.title;

  author.length = infoname.length;
  book.length = menu2[0].length;
  for ( var i=0; i < infoname.length; i++ ) {
     author.options[i].value = menu1[i][0];
     author.options[i].text  = menu1[i][0];
  }
  document.myform.main.selected = 0;
  for (var x=0; x < menu2[0].length; x++) {
     book.options[x].text = menu2[0][x];
     book.options[x].value = menu2[0][x];
  }     
  document.myform.title.selected = 0;
}

/******************************************************************

******/

function updatemenus ( what ) {
  var sel = what.selectedindex;

  if ( sel >= 0 && sel < menu1.length )
    var temp = menu2[sel];
  else
    var temp = new array ();
   
  what.form.title.length = temp.length;

  for ( var i = 0; i < temp.length; i++ ) {
    what.form.title.options[i].text = temp[i];
    what.form.title.options[i].value = temp[i];
  }
  what.form.title.selected=0;
}
// end of hiding -->
</script>
</head>

<body background="" bgcolor="#ffffff" text="#400040" link="#ff0080" vlink="#ff8080"

alink="#ff0000">
<center><h1>动态下拉菜单</h1></center>

<form name=myform action=test2.asp method=post><p>
分类:&nbsp;
<select name=my size=1 onchange="createmenus(document.myform.my.selectedindex)" class="smallsel">
<option selected></option>
<option value="info">杂文报</option>
<option value="infoa">书刊报</option>
</select>
<p>
作者: &nbsp;<select name="main" size=1 onchange="updatemenus(this)" class="smallsel">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;&nbsp;&nbsp;&nbsp;&nbsp;
<option>
<option>
</select>
<p>
标题:&nbsp;
<select name="title" size=1 class="smallsel">
<option>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

;
<option>
<option>
</select>
<input type=button value=submit onclick="parent.location.href=http://www.hebeidaily.com.cn">
</form>
</body>
</html>

()

相关文章:
© 2006   www.java-asp.net