<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <%@ include file="../../common/head.jsp"%>
    <link rel="stylesheet" type="text/css" href="../res/js//plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="../res/css/demo/webuploader-demo.css">
    <script type="text/javascript" src="../res/js/plugins/webuploader/webuploader.js"></script>
    <script type="text/javascript" src="../res/js/plugins/webuploader/uploader.js"></script>
	<cs:initFile/>
    <script type="text/javascript">
        $(function () {
            $("#airportDiv").hide();
            $("#airwaysDiv").hide();
        });

        function dotype(type){
            if(type == 0){
                $("#airportDiv").hide();
                $("#airwaysDiv").hide();
            }else if(type == 1){
                $("#airportDiv").show();
                $("#airwaysDiv").hide();
            }else if(type ==2){
                $("#airportDiv").show();
                $("#airwaysDiv").show();
            }
        }
        function doItem(id) {
            $('#airwaysId').empty();
            $('#airwaysId').html('<option value="">--无--</option>');

            $.getJSON('../machine/getAirways.cs', {
                'airportId': $('#airportId').val()
            }, function (data) {
                $.each(data, function (i, obj) {
                    $("#airwaysId").append('<option value="' + obj.id+'">' + obj.name + '</option>');
                });
            });
        }
    </script>
</head>

<body>
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
            	 <cs:form_validate formId="addUserForm"/>
                  <form class="form-horizontal" action="add.cs" id="addUserForm" method="POST">
                     <div class="form-group">
                          <label class="col-sm-3 control-label">项目名称：</label>
                          <div class="col-sm-6">
                              <input id="name" name="name" class="form-control" validate="{required:true}" validateMessage="{required:'请输入名称'}" >
                          </div>
                      </div>
                      
                      <div class="form-group">
                          <label class="col-sm-3 control-label">省：</label>
                          <div class="col-sm-6">
                      		<select id="provinceCode" name="provinceCode" class="form-control" validate="{required:true}" validateMessage="{required:'请输入名称'}">
                                <option value="" disabled selected hidden>省</option>
                            </select>
                            
                            <input type="hidden" id="province" name="province"/>
                          </div>
                      </div>
                      
                      <div class="form-group">
                          <label class="col-sm-3 control-label">市：</label>
                          <div class="col-sm-6">
                            <select id="cityCode" name="cityCode" class="form-control" validate="{required:true}" validateMessage="{required:'请输入名称'}">
                                <option value="" disabled selected hidden>市</option>                                
                            </select>
                            <input type="hidden" id="city" name="city"/>
                          </div>
                      </div>
                            
                      <!-- <div class="form-group">
                          <label class="col-sm-3 control-label">区 / 县：</label>
                          <div class="col-sm-6">
                            <select id="countyCode" name="countyCode" class="form-control" validate="{required:true}" validateMessage="{required:'请输入名称'}">
                                <option value="" disabled selected hidden>区 / 县</option>                               
                            </select>
                            <input type="hidden" id="county" name="county"/>
                          </div>
                      </div> -->
                            
                      
                     <div class="form-group">
                          <label class="col-sm-3 control-label">描述：</label>
                          <div class="col-sm-6">
                              <textarea id="info" name="info" class="form-control" style="height: 310px;"></textarea>
                          </div>
                      </div>
                     
                      <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-3 pull-left">
                                    <button class="btn btn-default btn-dlg-close">取消</button>
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                       </div>
                      
                  </form>
            </div>
        </div>

    </div>

<script type="text/javascript">
var curProvinceCode='41';//河南省
$.get('<%=basePath%>area/getProvice.cs',function(data){
	for(var i in data){
		var _option = '';
		if(curProvinceCode ==data[i].code ){
			 _option = '<option value="' + data[i].code + '" selected>' + data[i].name + '</option>';
			 $('#province').val(data[i].name);
		}else{
		 	_option = '<option value="' + data[i].code + '" >' + data[i].name + '</option>';
		}
		$('#provinceCode').append(_option);
	}
});  

if(curProvinceCode != ''){
	$.get('<%=basePath%>area/getByParentCode.cs',{'param': curProvinceCode}, function(data){
		for(var i in data){
		    var _option = '<option value="' + data[i].code + '" >' + data[i].name + '</option>';
			$('#cityCode').append(_option);
		}
	}); 
}

///省
$("#provinceCode").change(function(){
	var self = $(this);
	
	$('#cityCode').empty();
	    var _option = '<option>请选择</option>';
	$('#cityCode').append(_option);
	$('#city').val("");
	
	$('#countyCode').empty();
	    var _option = '<option>请选择</option>';
	$('#countyCode').append(_option);
	$('#county').val("");
	
	$('#townshipCode').empty();
	    var _option = '<option>请选择</option>';
	$('#townshipCode').append(_option);
	$('#township').val("");
	
	alert(self.val());
	
	$.get('<%=basePath%>area/getByParentCode.cs',{'param': self.val()}, function(data){
		for(var i in data){
				var _option = '<option value="' + data[i].code + '" >' + data[i].name + '</option>';
				$('#cityCode').append(_option);
			}
	}); 
	$('#province').val(self.find("option:selected").text());
});

///城市
$("#cityCode").change(function(){
	var self = $(this);
	$('#countyCode').empty();
	    var _option = '<option>请选择</option>';
	$('#countyCode').append(_option);
	$('#county').val("");
	
	$('#townshipCode').empty();
	    var _option = '<option>请选择</option>';
	$('#townshipCode').append(_option);
	$('#township').val("");
	
	
	<%-- $.get('<%=basePath%>area/getByParentCode.cs',{'param': self.val()}, function(data){
		for(var i in data){
				var _option = '<option value="' + data[i].code + '" >' + data[i].name + '</option>';
				//if(num == 1){
				    $('#countyCode').append(_option);
			   // }
			}
	}); --%> 
	
	$('#city').val(self.find("option:selected").text());
});

<%-- ///县、区
$("#countyCode").change(function(){
	var self = $(this);
	$('#townshipCode').empty();
	    var _option = '<option>请选择</option>';
	$('#townshipCode').append(_option);
	$('#township').val("");
	
	
	$.get('<%=basePath%>area/getByParentCode.cs',{'param': self.val()}, function(data){
		for(var i in data){
				var _option = '<option value="' + data[i].code + '" >' + data[i].name + '</option>';
				//if(num == 1){
				    $('#townshipCode').append(_option);
			   // }
			}
	}); 
	
	$('#county').val(self.find("option:selected").text());
}); --%>
</script>
</body>

</html>

