Here, I have treeview with checkboxes. My problem is how can I do the condition for checked checkboxes equal to 'y' and if unchecked checkboxes equal to 'n'. I have to update in database the value of chekbox which is column active that consist two value which is 'y' and 'n'. And I'm using AJAX in javaScript. It should be checked checkbox will get 'y' and unchecked checkbox get 'n' in database. But now, I'm currently just save checked checkbox equal to 'y' in database. Anyone have suggestion and what would be the best approach? For your information, I'm using treeview Kendo UI.
update.php
function deleteTemplate(){
global $ehorsObj;
$employeeID = $_SESSION['employeeID'];
$propertyID = $_SESSION['propertyID'];
$id = (isset($_POST['id']) ? $_POST['id'] : '');
$progid = (isset($_POST['progid']) ? $_POST['progid'] : '');
$sqlDelete = "DELETE FROM tblHrsPositionProgramTemplate
WHERE hrsPositionID = '".$id."'";
$ehorsObj->ExecuteData($sqlDelete, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
for($x=0; $x< sizeof($progid); $x++ )
{
$positionTemplateID = $ehorsObj->EHORS_PK("tblHrsPositionProgramTemplate");
$sqlAdd = "INSERT INTO tblHrsPositionProgramTemplate
SET positionTemplateID = '" . $positionTemplateID . "',
programID = '" . $progid[$x] . "',
hrsPositionID = '" . $id . "',
propertyID = '" . $propertyID . "',
employeeID = '" . $employeeID . "',
dateTimeEmployee = NOW() ";
$ehorsObj->ExecuteData($sqlAdd, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
$positionTemplateIDLog = $ehorsObj->EHORS_PK("tblHrsPositionProgramTemplateLog");
$sqlAddLog = "INSERT INTO tblHrsPositionProgramTemplateLog
SET positionTemplateIDLog = '" . $positionTemplateIDLog . "',
positionTemplateID = '" . $positionTemplateID . "',
programID = '" . $progid[$x] . "',
hrsPositionID = '" . $id . "',
propertyID = '" . $propertyID . "',
employeeID = '" . $employeeID . "',
dateTimeEmployee = NOW() ";
$ehorsObj->ExecuteData($sqlAddLog, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
}}
AJAX JavaScript
//AJAX call for button
$("#primaryTextButton").kendoButton();
var button = $("#primaryTextButton").data("kendoButton");
button.bind("click", function(e) {
var test = $("#dropdown").data("kendoDropDownList").value();
if(test == ""){
KendoAlert("Please select position");//dropdown
}
else{
$.ajax({
url: "../DesignationProgramTemplate/getTempJson.php",
type: "POST",
data: {
method: "addTemplate" ,
id: test,
progid: array
},
success: function () {
KendoAlert('Success'); }});
}
});