school_edit.html 3.8 KB
<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('School/school_list')}">学校列表</a></li>
        <li class="active"><a href="#">学校编辑</a></li>
    </ul>
    <form class="js-ajax-form" method="post" action="{:url('School/school_edit_post')}" role="form" style="margin-top: 20px;">
        <div class="input-group">
            <span class="input-group-addon">学校地区:</span>
            <select class="form-control" name="province" id="province" required>
                <option>请选择</option>
                <foreach name="$province" item="p">
                    <option value="{$p.name}">{$p.name}</option>
                </foreach>
            </select>
            <select class="form-control" name="city" id="city" required>
                <option>请选择</option>
            </select>
            <select class="form-control" name="county" id="county" required>
                <option>请选择</option>
            </select>
            <input type="text" class="form-control" name="region" value="{$data.region}" >
        </div>
        <br>
        <div class="input-group">
            <span class="input-group-addon">学校名称:</span>
            <input type="text" class="form-control" name="school" value="{$data.school}" >
        </div>
        <br>
        <div class="input-group">
            <span class="input-group-addon">学校类型:</span>
            <input type="text" class="form-control" name="type" value="{$data.type}" >
        </div>
        <br>
        <input type="hidden" name="id" value="{$data.id}">
            <div class="input-group">
                <span class="input-group-addon">年级:</span>
                <input type="text" class="form-control" name="grade_class_str" value="{$grade_class_str}" >
                <input type="hidden" name="grade_id_str" value="{$grade_id_str}">
            </div>
        <br>
        <button type="submit" class="btn btn-default">确定提交</button>
    </form>
</div>
</body>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $('#province').change(function(){
        var province_id = $('#province option:selected').val();
        $.ajax({
            url:"{:url('getArea')}",
            type:"GET",
            data:{'pid':province_id},
            success:function(data) {
                if(data.code==1){
                    var result = data;
                    var mydata = "<option value=''>请选择</option>";
                    for (var i = 0; i < result.data.length; i++) {
                        var data = result.data[i];
                        mydata += '<option value="'+data.name+'">'+data.name+'</option>';
                    }
                    $('#city').html(mydata);
                    $('#county').html("<option value=''>请选择</option>");
                }else {
                    alert('获取失败!');
                }
            }
        })
    })
    //获取区/县
    $('#city').change(function(){
        var city_id = $('#city option:selected').val();
        $.ajax({
            url:"{:url('getArea')}",
            type:"GET",
            data:{'pid':city_id},
            success:function(data) {
                if(data.code==1){
                    var result = data;
                    var mydata = "<option value=''>请选择</option>";
                    for (var i = 0; i < result.data.length; i++) {
                        var data = result.data[i];
                        mydata += '<option value="'+data.name+'">'+data.name+'</option>';
                    }
                    $('#county').html(mydata);
                }else {
                    alert('获取失败!');
                }
            }
        })
    })
</script>
</html>