school_edit.html 4.4 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">
            <php>$area = explode(' ',$data['region']);</php>
            <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}" <eq name="$area[0]" value="$p.name}">selected</eq> >{$p.name}</option>
                </foreach>
            </select>
            <select class="form-control" name="city" id="city" required>
                <option>请选择</option>
                <foreach name="$city" item="c">
                    <option value="{$c.name}" <eq name="$area[1]" value="$c.name}">selected</eq> >{$c.name}</option>
                </foreach>
            </select>
            <select class="form-control" name="county" id="county" required>
                <option>请选择</option>
                <foreach name="$county" item="co">
                    <option value="{$co.name}" <eq name="$area[2]" value="$co.name}">selected</eq> >{$co.name}</option>
                </foreach>
            </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_name = $('#province option:selected').val();
        $.ajax({
            url:"{:url('select_city')}",
            type:"GET",
            data:{'province_name':province_name},
            success:function(data) {
                var result = eval("(" + data + ")");
                if(result.code==20000){
                    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 if(result.code==40005){
                    alert('获取失败!');
                }
            }
        })
    })
    //获取区/县
    $('#city').change(function(){
        var city_name = $('#city option:selected').val();
        $.ajax({
            url:"{:url('select_county')}",
            type:"GET",
            data:{'city_name':city_name},
            success:function(data) {
                var result = eval("(" + data + ")");
                if(result.code==20000){
                    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 if(result.code==40005){
                    alert('获取失败!');
                }
            }
        })
    })
</script>
</html>