日期:2014-05-17  浏览次数:20400 次

JS语言
怎么用JS语言读出数据库里的级联

------解决方案--------------------
http://hi.baidu.com/goldou_com/item/adb50c109a36738e89a9566c

看看这个
------解决方案--------------------
楼主最好使用ajax来请求后台数据,根据返回值再来对DOM进行操作
------解决方案--------------------

本身是不可以这样。。

但是可以用AJAX去取数据

asp.net 可以考虑用JS写AJAX请求一般处理程序。。。返回JSON格式的数据
------解决方案--------------------
推荐AJAX
------解决方案--------------------
JScript code
 $.ajax({
                url: '../../UserManager/GetAllUsers/',
                type: 'POST',
                dataType: 'json',
                data: '',
                timeout: 30000,
                error: function () {
                    $.messager.alert('错 误', '系统出错,请重试!');
                },
                success: function (json) {
                    if (!json.iserr) {
                        var html = "<table style='width:100%;'>";
                        for (var x = 0; x < (parseInt(json.total / 6) + (json.total % 6 > 0 ? 1 : 0)); x++) {
                            html += "<tr>";
                            for (var y = 6 * x; y < ((json.total - 6 * x) > 6 ? 6 * (x + 1) : json.total); y++) {
                                html += "<td style='width:16%;'><input type='CheckBox' id='" + json.rows[y].id + "' value='" + json.rows[y].name + "'/>" + json.rows[y].name + "</td>";
                            }
                            html += "</tr>";
                        }
                        html += "</table>";
                        $("#allusers").empty().append(html);
                    }
                }
            });