function simpan_create() {
$("#btn_create").prop('disabled', true);$('#form_modal').parsley().reset();$('#form_modal').parsley().validate();if ($('#form_modal').parsley().isValid()) {$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}})$.ajax({url: "location/insert",type: "POST",data: $('#form_modal').serialize(),dataType: "json",success: function(response) {if (response.status == 200) {$("#modalForm").modal('hide');toastr["success"](response.message);locationTable.ajax.reload(null, false);if (response.stay == '1') {setTimeout(function() {show_create();}, 1000);}} else {alert('something wrong!!!');}$("#btn_create").prop('disabled', false);},statusCode: {422: function(data) {$.each(data.responseJSON.errors, function(key, value) {// Set errors on inputsif (key == 'location') {$('#err_room').html(value);$('#err_room').show();$("#btn_create").prop('disabled', false);//alert(value);// $('#input_kode_location').parsley().addError('customError', {// message: value// });}});$("#btn_create").prop('disabled', false);}}});} else {$("#btn_create").prop('disabled', false);}}
My Web Development Dairy
Minggu, 19 Februari 2023
Validasi Parsley Sebelum Submit
Jumat, 17 Februari 2023
Select2 Search And Add New Tag
$("#input_location").select2({tags: true,createTag: newtag,matcher: matchCustom,width: '100%',dropdownParent: $('#modalFormLabel'),});function newtag(params, data) {
var term = $.trim(params.term);term = term.toUpperCase();if (term === '') {return null;}return {id: term,text: term + " [Tambah Baru]",newTag: true // add additional parameters}}function matchCustom(params, data) {if ($.trim(params.term) === '') {return data;}if (typeof data.text === 'undefined') {return null;}var original = data.text;var term = params.term.toLowerCase();if (original.toLowerCase().indexOf(term) > -1) {return data;}if (data.newTag === false) {return {id: params.term,text: params.term,newTag: true};}return null;}
Sabtu, 21 Januari 2017
Query Database In Library Codeigniter
We usualy query in model, but sometime we need query in library codeigniter. This is sample code to do that.
function getStudent(){Glad can share ☺
$CI=& get_instance();
$q = $CI->db->query("select * from student");
return $q->result();
}
Jumat, 20 Januari 2017
Check All Checkbox Jquery
To check or uncheck all checkbox we can using this simple script
$('#cek_all').click(function (event) { //on clickGlad can share☺
if (this.checked) { // check select status
$('.checkboxs').each(function () { //loop through each checkbox
this.checked = true; //select all checkboxes with class "checkboxs"
});
} else {
$('.checkboxs').each(function () { //loop through each checkbox
this.checked = false; //deselect all checkboxes with class "checkboxs"
});
}
});
Rabu, 11 Januari 2017
PHP Generate Code XXYYMMXXXX Function
This PHP function to generate patter code xxYYMMxxxx ex.GG17010002
function get_new_code_opb()
{
$code=''; // you can fill this using prev code with same pattern
$kode=substr($code, -4);
$num=(int)$kode;
$month=substr($code, -6,2);
if($num==0 || $num==null || $month!=$month_now)
{
$temp = 1;
}
else
{
$temp=$num+1;
}
if($dt==''){
$today = date('ym');
}
$id="XX".$today."".str_pad($temp, 4, 0, STR_PAD_LEFT); //XX can change into your prefix
return $id;
}
This code return by 1 if month changed
function get_new_code_opb()
{
$code=''; // you can fill this using prev code with same pattern
$kode=substr($code, -4);
$num=(int)$kode;
$month=substr($code, -6,2);
if($num==0 || $num==null || $month!=$month_now)
{
$temp = 1;
}
else
{
$temp=$num+1;
}
if($dt==''){
$today = date('ym');
}
$id="XX".$today."".str_pad($temp, 4, 0, STR_PAD_LEFT); //XX can change into your prefix
return $id;
}
This code return by 1 if month changed
Selasa, 10 Januari 2017
Javascript Popup Function
This is example code for pupup new window using javascript
function show_popup() //
{
var width = 800;
var height = 500;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height+',scrollbars=yes';
params += ', top='+top+', left='+left;
window.open('popup.php','',params);
}
function show_popup() //
{
var width = 800;
var height = 500;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height+',scrollbars=yes';
params += ', top='+top+', left='+left;
window.open('popup.php','',params);
}
Langganan:
Komentar (Atom)