<form action="receive.manage.php?action=modisave" method="POST" style="line-height:35px" id="form_modi">
<table class="from_table">
  <tr>
    <th class="th2"><tpl> $langRConsigneeName </tpl>：</td>
    <td width="480" align="left" class="td1"><input name="txtReceiveName" type="text" class="txtinput" id="txtReceiveName" value="<tpl> $receive_array[0].receive_name </tpl>" /></td>
  </tr>
  <tr>
    <th class="th2"><tpl> $langRLocalityZone </tpl>：</td>
    <td width="480" align="left" class="td1"> <input type="hidden" name="area_id" id="area_id" value="<tpl> $receive_array[0].receive_area_id </tpl>"/>
		<select id="area_c1" class="searchformselect" name="area_c1" style="width: 120px">
			<option valus="" selected></option>
			<tpl> foreach item = parent from = $area_array </tpl>
			<option <tpl> if $sel_area[0].area_id eq $parent.area_id </tpl>selected="selected"<tpl> /if  </tpl> value="<tpl>$parent.area_id</tpl>||<tpl>$parent.is_parent</tpl>"><tpl> $parent.area_name </tpl></option>
			<tpl> /foreach </tpl>
		</select>
		<select class="searchformselect" id="area_c2" style="width: 120px" name="area_c2">
			<option valus="<tpl> $sel_area[1].area_id </tpl>" selected><tpl> $sel_area[1].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="area_c3" style="width: 120px" name="area_c3">
			<option valus="<tpl> $sel_area[2].area_id </tpl>" selected><tpl> $sel_area[2].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="area_c4" style="width: 120px" name="area_c4">
			<option valus="<tpl> $sel_area[3].area_id </tpl>" selected><tpl> $sel_area[3].area_name </tpl></option>
		</select>
	</td>
  </tr>
  <tr>
    <th class="th2"><tpl> $langRParticularAddress </tpl>：</td>
    <td width="480" align="left" class="td1"><textarea name="txtAddress"  cols="50" rows="3" id="txtAddress" class="tarea"><tpl> $receive_array[0].address </tpl>
    </textarea></td>
  </tr>
  <tr>
    <th class="th2"><tpl> $langReceivePostalcode </tpl>：</td>
    <td width="480" align="left" class="td1"><input name="txtZip" type="text" id="txtZip" class="txtinput" value="<tpl> $receive_array[0].zip </tpl>" /></td>
  </tr>
  <tr>
    <th class="th2"><tpl> $langRPhone </tpl>：</td>
    <td width="480" align="left" class="td1"><input name="txtPhone" type="text" class="txtinput" id="txtPhone" value="<tpl> $receive_array[0].phone </tpl>" /></td>
  </tr>
  <tr>
    <th class="th2"><tpl> $langRMobileTelephone </tpl>：</td>
    <td width="480" align="left" class="td1"><input name="txtMobilephone" type="text" id="txtMobilephone" class="txtinput" value="<tpl> $receive_array[0].mobilephone </tpl>" /></td>
  </tr>
  <tr>
    <td></td>
    <td width="480"><span class="btn_left">
      <input type="submit" name="submit" class="btn_submit" value="<tpl> $langRSubmit </tpl>" /></span>
	  <span class="btn_left"><input id="butt_list" type="button" class="btn_submit" value="<tpl> $langRReturnList </tpl>" /></span></td>
  </tr>
</table>

<input type="hidden" name="receive_id" value="<tpl> $receive_array[0].receive_id </tpl>">
<input type="hidden" name="member_id" value="<tpl> $receive_array[0].member_id </tpl>">
</form>
<script language="javascript">
$(document).ready(function() {
	
	hideMessage();
	
	//返回列表
	$('#butt_list').click(function(){
		ShowDiv = "result_content";
		getPageContent("receive.manage.php?action=ajax_list&curpage=<tpl>$curpage</tpl>");
	})
	
	var options_modi = {
		beforeSubmit:  function(){showLoading(showText);},
		success:       function(msg){
						hideLoading();
						showMessage(msg.message,msg.type);
						if(msg.type == '1'){
							ShowDiv = "result_content";
							getPageContent("receive.manage.php?action=ajax_list&curpage=<tpl>$curpage</tpl>");
						}
					},
		type:      'post',
		dataType:  'json'
	};
	$("#form_modi").validate({
		errorClass: "wrong",
		rules: {
			txtMemberName: {required:true},
			txtReceiveName: {required:true},
			area_id: {required:true},
			txtAddress: {required:true},
			txtZip: {required:true},
			txtPhone: {required:true,number:true},
			txtMobilephone: {number:true}
		},
		messages: {
			txtMemberName: {required:"<tpl> $langRAccountsCannotNull </tpl>"},
			txtReceiveName: {required:"<tpl> $langRConsigneeNameNotNull </tpl>"},
			area_id: {required:"<tpl> $langRLocalityProvinceCanNotNull </tpl>"},
			txtAddress: {required:"<tpl> $langRParticularAddressNotNull </tpl>"},
			txtZip: {required:"<tpl> $langRPostalcodeNotNull </tpl>"},
			txtPhone: {required:"<tpl> $langRPhoneCannotNull </tpl>",number:"<tpl> $langRPhoneIsNumber </tpl>"},
			txtMobilephone: {number:"<tpl> $langRMobileTelephoneIsNumber </tpl>"}			
		},
		submitHandler: function() {
			$('#form_modi').ajaxSubmit(options_modi);
		}
	});	
});
//地区选择
function tonext_area(whos) {
	$(whos).change(
		function(){
			var valarray=$(this).val().split('||');	
			$('#area_id').val(valarray[0]);
			if (valarray[1]=='1') {
				$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langCDataToLoading </tpl></option>');
				$.get(
					'../home/tohtml.php',
					{action:'get_area',id:valarray[0],random_number:Math.random()},
					function(data){
						DataArray = data.split("|||");
						var a='';
						for (var i = 0; i<DataArray.length-1; i++) {
							att=DataArray[i].split("||");
							id=att[0];
							cla=att[2];
							a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';
						}
						
					$(whos).next().removeAttr('disabled').html('<option value="" selected="selected"></option>'+a).nextAll().html('');
					tonext_area($(whos).next());
					}
				)
			} else {
				$(whos).nextAll().html('').attr('disabled','true');
			};
		}
	)
};
$(document).ready(function() {
	tonext_area('#area_c1');
});
</script>
