• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

给你一个JS实现列表连动的例子

发布: 2007-7-01 15:06 | 作者: admin | 来源: | 查看: 23次 | 进入软件测试论坛讨论

领测软件测试网 <script language="JavaScript">
function show_board(board_top,board){
    var select_index,select_id,select_name,i,j;
    select_index=board_top.selectedIndex;
    select_id=board_top.options[select_index].value;
    form1.parent_id.value=select_id;
    form1.board_top_add.value=board_top_arr[select_id].name;
    form1.note_top_add.value=board_top_arr[select_id].note;
    form1.manager_top_add.value=board_top_arr[select_id].manager;
    for(i=board.length-1;i>=0;i--){
        board.remove(i);
    }
    for(i=0;i<board_arr[select_id].length;i++){
        if(typeof(board_arr[select_id][i])=="object"){
            var oOption = document.createElement("OPTION");
            oOption.text=board_arr[select_id][i].name;
            oOption.value=board_arr[select_id][i].id;
            //document.all.MyList.add(oOption);
            board.add(oOption);
        }
    }
    
}
function select_board(board){
    var select_index,select_id;
    select_index=board.selectedIndex;
    select_id=board.options[select_index].value;
    form1.board_id.value=select_id;
    form1.board_add.value=board_arr[form1.parent_id.value][select_id].name;
    form1.note_add.value=board_arr[form1.parent_id.value][select_id].note;
    form1.manager_add.value=board_arr[form1.parent_id.value][select_id].manager;
}
function W(text){
    document.write(text);
}
function board_func(id,name,note,manager){
    this.id=id;
    this.name=name;
    this.note=note;
    this.manager=manager;
}
var board_arr=new Array();
var board_top_arr=new Array();
<?php
$board_top_option="";
$query="select board_id,board_name,board_note,board_manager from board where board_level=@#1@# order by board_id";
$result_top=mysql_db_query($dbname,$query);
while($myrow_top=mysql_fetch_array($result_top)){
    $board_top_option.="<option value=@#$myrow_top[board_id]@#>$myrow_top[board_name]</option>\n";
    echo "board_top_arr[$myrow_top][board_id]]=new board_func(@#$myrow_top[board_id]@#,@#$myrow_top[board_name]@#,@#$myrow_top[board_note]@#,@#$myrow_top[board_manager]@#);\n";
    $query="select board_id,board_name,board_note,board_manager from board where board_level=@#2@# and parent_id=@#$myrow_top[board_id]@# order by board_id";
    $result=mysql_db_query($dbname,$query);
    echo "var tmp_arr=new Array();\n";
    while($myrow=mysql_fetch_array($result)){
        echo "tmp_arr[$myrow][board_id]]=new board_func(@#$myrow[board_id]@#,@#$myrow[board_name]@#,@#$myrow[board_note]@#,@#$myrow[board_manager]@#);\n";
    }
    echo "board_arr[$myrow_top][board_id]]=tmp_arr;\n";
}
?>

function checkform(text){
    if(text.value.length==0){
        alert("请输入要添加的版面名称!");
        return false;
    }
    return true;
}
</script>

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网