用json做了一个二级联运下拉列表,JS代码如下:
    <script type="text/javascript">
        
        function areaid()
        {
            document.getElementById("aid").value = document.getElementById("area_id").options[document.getElementById("area_id").selectedIndex].value;
        }        function initPro() {
        
            var option3 = '';
            $.getJSON("../Json/gsPlace.ashx",function(jsonData) {
                $.each(jsonData, function(index, indexItems) {
                option3 += "<option value=" + indexItems.id + ">"
                + indexItems.name + "</option>";
                });
                $("#origin_id").append(option3);
                $("#origin_id").bind("change", function() {
                document.getElementById("oid").value = document.getElementById("origin_id").value; 
                area_id(jsonData);
                areaid();
                })
            });
           
        function area_id(data) {
            var option4 = '';
            var selectedIndex = $("#origin_id :selected").text();
            $("#area_id").empty();
            if($("#origin_id :selected").val() == ""){
                $("#area_id").append("<option value=\"\">请选择区域</option>");
            }
            $.each(data, function(index, indexItems) {
                var proName = indexItems.name;
                $.each(indexItems.items, function(index, indexItems) {
                    if (indexItems.parentNode != selectedIndex) {
                    return;
                    } else {
                option4 += "<option value=" + indexItems.id + ">"
                + indexItems.name + "</option>";
                    }
                })
            });
            $("#area_id").append(option4);
            };
            };
       
       
       $(function() {
           initPro();
       });
    </script>问题:
1. 由于数据是动态读入的,如何可以让下拉列表默认选中指定的值?这个值是从数据表中读取到的。
2. 并且,联动的下拉列表也要显示从数据表中读到到的另一个值。请教,谢谢。^_^