update]');
		var result = '';

		if (arabicName.val() == '') {
			arabicName.parent().parent().addClass('has-error');
			return;
		}else{
			arabicName.parent().parent().removeClass('has-error');
			result +='1';
		}
		if (englishName.val() == '') {
			englishName.parent().parent().addClass('has-error');
			return;
		}else{
			englishName.parent().parent().removeClass('has-error');
			result +='2';
		}
		if (studentNumber.val() == '') {
			studentNumber.parent().parent().addClass('has-error');
			return;
		}else{
			studentNumber.parent().parent().removeClass('has-error');
			result +='3';
		}
		if (nationality.val() == '') {
			nationality.parent().parent().addClass('has-error');
			return;
		}else{
			nationality.parent().parent().removeClass('has-error');
			result +='4';
		}
		if (divisionID.val() == '') {
			divisionID.parent().parent().addClass('has-error');
			return;
		}else{
			divisionID.parent().parent().removeClass('has-error');
			result +='5';
		}
		if (gradeID.val() == '') {
			gradeID.parent().parent().addClass('has-error');
			return;
		}else{
			gradeID.parent().parent().removeClass('has-error');
			result +='6';
		}
		if (roomID.val() == '') {
			roomID.parent().parent().addClass('has-error');
			return;
		}else{
			roomID.parent().parent().removeClass('has-error');
			result +='7';
		}
		if (studentID.val() == '') {
			studentID.parent().parent().addClass('has-error');
			return;
		}else{
			studentID.parent().parent().removeClass('has-error');
			result +='8';
		}
		if (fatherID.val() == '') {
			fatherID.parent().parent().addClass('has-error');
			return;
		}else{
			fatherID.parent().parent().removeClass('has-error');
			result +='6';
		}
		if (fatherJob.val() == '') {
			fatherJob.parent().parent().addClass('has-error');
			return;
		}else{
			fatherJob.parent().parent().removeClass('has-error');
			result +='10';
		}
		if (motherName.val() == '') {
			motherName.parent().parent().addClass('has-error');
			return;
		}else{
			motherName.parent().parent().removeClass('has-error');
			result +='11';
		}						
		if (stage.val() == '') {
			stage.parent().parent().addClass('has-error');
			return;
		}else{
			stage.parent().parent().removeClass('has-error');
			result +='12';
		}
		if (username.val() == '') {
			username.parent().parent().addClass('has-error');
			return;
		}else{
			username.parent().parent().removeClass('has-error');
			result +='13';
		}
		
		if (status.val() == '') {
			status.parent().parent().addClass('has-error');
			return;
		}else{
			status.parent().parent().removeClass('has-error');
			result +='14';
		}
		if (result == '1234567861011121314') {
			$.ajax({
				type:'ajax',
				method:'post',
				url:'<?php echo base_url()?>Student/updatestudent',
				data:data,
				async:false,
				dataType:'json',
				success:function(response){
					if (response.success) {
						$('.alert-success').html('Updated student account successfully.').fadeIn().delay(2000).fadeOut('slow');
						load_student_data(1);
						// go to top page
	              		$('html, body').animate({ scrollTop: 0 }, 0);						
					}
				}
			});
		}
	});	
  	function load_data_student(data)
	{
		var id = data;
		var divID = ""; // to set divisionID
		var graID = ""; // to set gradeID
		var romID =""; // to set roomID

		// load student data
  		$.ajax({
  			type:'ajax',
  			method:'get',
  			url:'<?php echo base_url()?>Student/getdatabyid',
  			data:{id:id},
  			async:false,
  			dataType:'json',
  			success:function(data){
  				$('input[name=stuID]').val(data.stuID);
  				$('input[name=arabicName_update]').val(data.arabicName);
  				$('input[name=englishName_update]').val(data.englishName);
  				$('input[name=studentID_update]').val(data.studentID);
  				$('input[name=Nationality_update]').val(data.Nationality);
  				$('select[name=divisionID_update]').val(data.divisionID);
  				$('select[name=gradeID_update]').val(data.gradeID);
  				$('select[name=roomID_update]').val(data.roomID);
  				$('input[name=studentIDcard_update]').val(data.studentIDcard);
  				$('input[name=start_school_update]').val(data.start_school);
  				$('input[name=fatherIDcard_update]').val(data.fatherIDcard);
  				$('input[name=fatherJob_update]').val(data.fatherJob);
  				$('input[name=motherName_update]').val(data.motherName);
  				$('select[name=status_update]').val(data.status);
  				$('select[name=stage_update]').val(data.stage);
  				$('input[name=username_update]').val(data.username);
  				$('input[name=fatherMobile_update]').val(data.fatherMobile);
  				$('input[name=motherMobile_update]').val(data.motherMobile);
  				$('select[name=student_status_update]').val(data.student_status);
  				$('select[name=secondLanguage_update]').val(data.secondLanguage);
  				
  				// created to send as a get to selected from selected box
  				divID = data.divisionID;
  				graID = data.gradeID;
  				romID = data.roomID;

  			},
  			error:function(){
  				alert('Could not get data');
  			}
  		});
  		// load division
		$.ajax({
			type:'ajax',
			method:'get',
			data:{divi:divID},
			url:'<?php echo base_url()?>Student/retrivedivisionByid',
			dataType:'json',
			success:function(data)
			{
				$('#divisionID').html(data);
			}
		});
		// load grades
		$.ajax({
			type:'ajax',
			method:'get',
			data:{gra:graID},
			url:'<?php echo base_url()?>Student/retrivegradeByid',
			dataType:'json',
			success:function(data)
			{
				$('#gradeID').html(data);
			}
		});
		// load rooms
		$.ajax({
			type:'ajax',
			method:'get',
			data:{rom:romID},
			url:'<?php echo base_url()?>Student/retriveroomByid',
			dataType:'json',
			success:function(data)
			{
				$('#roomID').html(data);
				$('#roomID').prop('disabled', false);
			}
		});
	}
	// load room for update
	$('#divisionID').on('change', function(){