记录我的一些生活写照、无聊的牢骚、内心世界的活动 注册 | 登陆

把我网站上的二级下拉列表也贡献出来

<html>
<head>
<title>二级别下拉列表</title>
<script language="JavaScript">
<!--
/*
// +----------------------------------------------------------------------+
// | 无限级下拉列表 Version:dOption 0.1                                  |
// | http://www.moocky.com                                                  |
// | http://www.moocky.net                                                   |
// +----------------------------------------------------------------------+
// | Copyright (c) 2006                                                           |
// | Moocky Mark(木目子).                                                        |
// | Create Date:2006-07-19                                                 |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Authors:   Moocky Mark                                                    |
// | QQ:        44333697                                                          |
// | MSN:       moocky@hotmail.com                                        |
// | Email:     moocky@moocky.net                                         |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | LastUpdate:2006-07-19                                                  |
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | 请尊重作者的劳动成果,保留版权信息                                     |
// +----------------------------------------------------------------------+

*/
function c(s,i){this.s=s;this.i=i;}
function p(value,text){this.value=value;this.text=text;}
var where = new Array(4);
where[0]= new c(new p("wenxue","心情文学"),
        new Array(new p("topic","标题"),
             new p("user","作者"),
             new p("all","全文")));
where[1]= new c(new p("enjoy","文学鉴赏"),
        new Array(new p("topic","标题"),
             new p("litterateur","文人"),
             new p("all","全文")));
where[2]= new c(new p("forum","文学论坛"),
        new Array(new p("topic","标题"),
             new p("user","作者"),
             new p("all","全文")));
where[3]= new c(new p("news","站内新闻"),
        new Array(new p("topic","标题"),
             new p("all","全文")));
function loadSelect(){
 with(document.getElementById("sel1")){
  length = where.length;
  for(var i=0;i< where.length;i++){
   var p=where[i].s;
   options[i].value = p.value;
   options[i].text  = p.text;
  }
  onchange=Function("chgSelect();");
 }
 chgSelect();
}

function chgSelect(){
 with(document.getElementById("sel1")){
  for(var i=0; i < where.length ; i++){
   if(options[selectedIndex].value==where[i].s.value)
    var p = where[i].i;
  }
 }
 
 with(document.getElementById("sel2")){
  length = p.length;
  for(i=0;i < p.length;i++){
   options[i].value = p[i].value;
   options[i].text  = p[i].text;
  }
 }
}
//-->
</script>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="search" method="post" action="" target="_blank">
  <tr>
    <td width="42%" align="right" height="40">关键词:</td>
    <td width="58%" height="40"><input type="text" name="keyword" class="input" style="width:80px;"></td>
  </tr>
  <tr>
    <td width="42%" align="right" height="40">栏 目:</td>
    <td width="58%" height="40"><select id="sel1" name="d"></select></td>
  </tr>
  <tr>
    <td width="42%" align="right" height="40">字 段:</td>
    <td width="58%" height="40"><select id="sel2" name="type"></select>
    </td>
  </tr>
  <tr align="center">
    <td colspan="2" height="40"><input type="submit" name="Submit" value="搜  索"></td>
  </tr>
</form>
</table>
<script language="javascript">
loadSelect();
</script>
</body>
</html>

Tags: javascript

« 上一篇 | 下一篇 »

只显示10条记录相关文章

Trackbacks

点击获得Trackback地址,Encode: UTF-8 点击获得Trackback地址,Encode: GB2312 or GBK 点击获得Trackback地址,Encode: BIG5

发表评论

评论内容 (必填):