频道直达 - 专题 - 新闻 - 技巧 - 组网 - 开发 - 安全 - web编程 - 图像 - 操作系统 - 数据库 - 教育 - 旅游 - 健康 - 时尚 - 驱动 - 软件 - 游戏 - 多媒体 - ERP - 讨论组

javascript中取得下拉框的值太麻烦(下拉框联动)

来源: 作者: 出处:巧巧读书 2006-03-11 进入讨论组
谢 谢 收 藏 http://www.qqread.com/jscript/c122774501.html
  在 JS中获取下拉框的值真是要费很多周章,比起在ASP。NET中来就麻烦多了


< html >
< head >
< title >List< /title >
< meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
< script LANGUAGE="javascript" >
< !--
var onecount;
onecount=0;
    
subcat = new Array();
subcat[0] = new Array("徐汇区","01","001");
subcat[1] = new Array("嘉定区","01","002");
subcat[2] = new Array("黄浦区","01","003");
subcat[3] = new Array("南昌市","02","004");
subcat[4] = new Array("九江市","02","005");
subcat[5] = new Array("上饶市","02","006");

onecount=6;

function changelocation(locationid)
    {
    document.myform.smalllocation.length = 0; 

    var locationid=locationid;
    var i;
    document.myform.smalllocation.options[0] = new Option('====所有地区====','');
    for (i=0;i <  onecount; i++)
        {
            if (subcat[i][1] == locationid)
            { 
            document.myform.smalllocation.options[document.myform.smalllocation.length]
 = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    

//-- >
< /script >
< /head >
< body >
< form name="myform" method="post" >
    < select name="biglocation" 
onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)" >
        < option value="01" selected >上海< /option >
        < option value="02" >江西< /option >
    < /select >
    < select name="smalllocation" > 
        < option selected value="" >==所有地区==< /option >
    < /select >
< /form >
< script LANGUAGE="javascript" > 
< !-- 
    changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value); 
//-- > 
< /script >
< /body >
< /html >进入讨论组讨论。
收藏此文】【 】【打印】【关闭
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
巧巧读书宗旨
相关专题
讨论组问题推荐
站内各频道最新更新文档
站内最新制作专题
热门关键字导读
Photoshop教 程照片处理 照片制作 PS快捷键 抠图
计 算 机 故 障XP系统修复
艺 术 与 设 计设计 流媒体 设计欣赏 边框
计 算 机 安 全ARP
站内频道文章精选
巧巧电脑频道编辑信箱  告诉我们您想看的专题或文章