$(document).ready(function() {
	$('#butsaveR').on('click', function() {
		$("#butsaveR").attr("disabled", "disabled");
		var userid = $('#users_drop').val();
		var rightid = $('#user_rights').val();

		if(userid!="" && rightid!=""){

			if(userid=='1') {
			alert("ADMIN'S RIGHT CANNOT BE CHANGED !!");
			}
			else {

			$.ajax({
				url: "changeRights.php",
				type: "POST",
				data: {
					userid: userid,
					rightid: rightid	
				},
				cache: false,
				success: function(dataResult2){
					var dataResult2 = JSON.parse(dataResult2);
					if(dataResult2.statusCode2==200){
						$("#butsaveR").removeAttr("disabled");
						$('#changeRForm').find('input:text').val('');
						$("#successR").show();
						$('#successR').html('User Right Updated Successfully !');					
					}
					else if(dataResult2.statusCode2==201){
					   alert("Error occured !");
					}
					
				}
			});
			}
		}
		else{
			alert('Please fill all the field !');
		}
	});
});