<form name="payeeForm" id="payeeForm">
<div class="col-md-8">
<div class="form-group row">
<label for="payee_name">Payee Name</label>
<div class="input-group">
<input type="text" class="form-control col-md-12" name="payee_name" id="payee_name" /> 
</div>
</div>

</div>

<input type="hidden" name="type" value="<?php echo $_REQUEST['type']?>">
<input type="hidden" name="FUNCTION" value="createPayee">
</form>


 
<script>
$('#popupBox .modal-header').html('<a href="javascript:void(0)" class="sa">New Payee</a>')
$('#popupBox .modal-footer').html('<a id="btnConfirm" href="javascript:void(0)" class="btn btn-info mr-5">Save</a><a id="btnCancel" href="javascript:void(0)" class="btn btn-danger">Cancel</a>');
$("#btnCancel").click(function(){$('#popupBox').modal('hide');})


$("#btnConfirm").click(function(){
var name=$("#payeeForm input[name=payee_name]").val();
//alert(reg)
if(name===""){
response('danger','YOU MUST ENTER A PAYEE NAME');
}
else{$("#payeeForm").submit()}
})

$("#payeeForm").submit(function(event){
event.preventDefault();
var name=$("#payeeForm input[name=payee_name]").val();
$.ajax({
url:'includes/finance/finance_functions.php',
type:'POST',
data:$('#payeeForm').serialize(),
success:function(result){//debug(result)
if($.trim(result)=="success"){
response('success','Your Payee has been saved successfully');
$('#payee').append('<option value="'+name+'" SELECTED>'+name+'</option>');
$('#popupBox').modal('hide')
}
}
});
});

</script>