/*********************** ADD / EDIT **************************/
function user_screen_add(form_name, sub_screen, edit_id, action) { 
    $.ajax({
        type: "POST",
        url: "user_screen_db.php",  // same folder as user_screen.php
        data: {
            form_name: form_name,
            sub_screen: sub_screen,
            edit_id: edit_id,
            action: action
        },
        success: function(msg) {
            $("#user_screens_div").html(msg);
            // Close popup if you use one
            window.close();
             window.opener.location.reload(true);
        },
        error: function(xhr, status, error) {
            alert("Add/Edit failed: " + error);
        }
    });
}

/*********************** DELETE **************************/
function user_sub_screen_delete(screen_id, sub_screen) {
 alert(karthi);
    if (!confirm('Are you sure you want to delete?')) return;

    $.ajax({
        type: "POST",
        url: "user_screen_db.php",  // same as add/edit
        data: {
            screen_id: screen_id,
            sub_screen: sub_screen,
            action: 'del_screen_sub'
        },
        success: function(response) {
            $("#user_screens_div").html(response);
            alert("Deleted Successfully");
        },
        error: function(xhr, status, error) {
            alert("Deletion failed: " + error);
        }
    });
}
