$(document).ready( function () {
});
Category: Javascript
Colorbox – Closing the window
function closeMyColorbox() {
window.parent.$.colorbox.close();
}
Javascript – Yes / No NOTY buttons
function deleteDocs () {
var uploadid = <?php echo ($uploadid); ?>;
$.noty.closeAll()
var n = noty({
text : ‘<?php echo $translation->getValue(“CESDoyouwanttoDELETEyourUPLOADEDDOCUMENTSfromthedatabase”)?>’,
type : ‘confirm’,
dismissQueue : false,
layout : ‘top’,
theme : ‘defaultTheme’,
buttons : [
{addClass: ‘btn btn-success’, text:'<?php echo (“Yes”)?>’, onClick:
function($noty) {
$noty.close();
$.post(‘inl_sev_066_J_ver.php’,{“UPLOADID” : uploadid,
“event” :’STOOR’}, function(response) {
// alert (“Javascript object – response : ” + JSON.stringify(response, null, 4));
if (response[0].success == “Y”) {
$.noty.closeAll();
var n = noty({
dismissQueue: false,
timeout : 2000,
text : response[0].message,
type : ‘success’,
layout : ‘top’
});
} else {
$.noty.closeAll();
var n = noty({
dismissQueue: false,
text : response[0].message,
type : ‘error’,
layout : ‘top’
});
}
}, ‘json’)
}
}, // YES Button
{addClass: ‘btn btn-danger’, text:'<?php echo (“No”)?>’, onClick:
function($noty) {
$noty.close();
noty({text:'<?php echo (“Cancelled”)?>’, type: ‘error’,timeout:1000});
} // “NO” Button
}
] // Noty button array
}) // Noty
}
Javascript – Disabling a button
document.getElementById(“btnStore”).disabled = true;
Javascript / JQuery – $.getJSON and $.post
$.getJSON(‘inl_sev_034_E_vrs.php?TEMPLATE=’ + template + “&DEPT=” + dept, function(data) {
var myData = data;
// alert (“Javascript object – data : ” + JSON.stringify(data));
});
$.post(‘inl_sev_035_J_skp.php’,{
“DEPT” : dept,
“TEMPLATE” : template,
“VERSION” : version,
“MYDATA” : myData,
“event” :’STOOR’}, function(response) {
}, ‘json’)
Javascript – Date and Time information
var YYYY = new Date().getFullYear();
var MM = new Date().getMonth() + 1;
var DD = new Date().getDate();
var hh = new Date().getHours();
var mm = new Date().getMinutes();
var ss = new Date().getSeconds();
var version = YYYY + “-” + MM +”-” + DD + “_” + hh + “_” + mm + “_” + ss;
PHP – Retrieving form field values on submit then executing a javascript function
Jquery – AJAX Post()
function writeLog (lquestionnaire, lversion, ltak){
var activity = “EVALUATION – Questionnaire: ” + lquestionnaire + ” Version: ” + lversion + ” Branch: ” + ltak
$.post(‘inl_sev_067_J_skp.php’, {“ACTIVITY” : activity}, function(response) {
}, ‘json’)
}
Javascript – Encoding escape characters in strings
question = escape(question);
Populate select 2 with JSON data

function getTak (questionnaire, version) {
$(‘#_TAK’).children(‘option:not(:first)’).remove();
$.post(‘inl_sev_055_J_nvg.php’,{“QUESTIONNAIRE” : questionnaire, “VERSION” : version}, function(data) {
var i;
for (i = 0; i < data.length; i++) {
text = data[i];
newOption = new Option(text, i, false, false);
$(‘#_TAK’).append(newOption).trigger(‘change’);
}
}, ‘json’);
}
// — Parameters input ——————————————————–
$questionnaire = (isset($_REQUEST[‘QUESTIONNAIRE’])) ? $_REQUEST[‘QUESTIONNAIRE’] : ”;
$version = (isset($_REQUEST[‘VERSION’])) ? $_REQUEST[‘VERSION’] : ”;
// — Define containers ——————————————————-
$terugvoer = array();
// — Retrieve the present list of versions ———————————–
$sql = “SELECT DISTINCT _TAK FROM questionnaire WHERE _TEMPLATE = ‘$questionnaire’ AND _VERSION = ‘$version’ “;
$db = new MysqliDb(‘CES’);
$selectStatus = $db->rawQuery($sql);
if ($selectStatus > 0) {
foreach ($selectStatus as $row) {
$terugvoer[] = $row[‘_TAK’];
}
}
echo json_encode($terugvoer);
?>

You must be logged in to post a comment.