var org_id = kariah_id = 146;
function swal_ok_countdown(title, message, timer = null, redirect = null) {
let countdown = timer;
let intervalId;
const swalInstance = Swal.fire({
title: title,
html: message,
showConfirmButton: true,
confirmButtonText: timer > 0 ? `OK (${countdown})` : 'OK',
allowOutsideClick: false,
allowEscapeKey: false,
allowEnterKey: false
});
if (timer > 0) {
intervalId = setInterval(() => {
countdown--;
if (countdown <= 0) {
clearInterval(intervalId);
swalInstance.close();
} else {
swalInstance.update({
confirmButtonText: `OK (${countdown})`
});
}
}, 1000);
}
swalInstance.then((result) => {
if (intervalId) clearInterval(intervalId);
if (redirect === 'reload') {
window.location.reload();
} else if (typeof redirect === 'string' && redirect.length > 0) {
window.location.href = redirect;
}
});
}
function notify(msg,typealert){
if (typealert=='alert'){
var icon = ' ';
} else if (typealert=='success'){
var icon = ' ';
} else if (typealert=='warning'){
var icon = ' ';
} else if (typealert=='error'){
var icon = ' ';
} else if (typealert=='info'){
var icon = ' ';
}
new Noty({
text: icon+msg,
type: typealert,
timeout: 3500,
killer: true,
progressBar: true,
theme: 'metroui'
}).show();
}
function showmap(lat,lang,where,zoomratio) {
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var latlng = new google.maps.LatLng(lat,lang);
directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: zoomratio,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP ,
travelMode: google.maps.TravelMode.DRIVING
};
var map = new google.maps.Map(document.getElementById(where), myOptions);
directionsDisplay.setMap(map);
var image = '../../assets/images/location.png';
var myLatLng = new google.maps.LatLng(lat,lang);
var beachMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
}
function get_location(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(GEOprocess, GEOdeclined);
}else{
swal.fire('Sorry','Your browser does not allow location to be detected',"danger");
//document.getElementById('geo').innerHTML = 'Your browser sucks. Upgrade it.';
}
}
function get_directions(dest_lat,dest_lng){
var ori_lat = $("#latitude").val();
var ori_lng = $("#longitude").val();
var latlng = new google.maps.LatLng(ori_lat,ori_lng);
var directionsService = new google.maps.DirectionsService;
var directionsDisplay = new google.maps.DirectionsRenderer;
directionsService.route({
origin: new google.maps.LatLng(ori_lat,ori_lng),
destination: new google.maps.LatLng(dest_lat,dest_lng),
travelMode: google.maps.TravelMode.DRIVING
}, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP ,
travelMode: google.maps.TravelMode.DRIVING
};
var map = new google.maps.Map(document.getElementById('map_box'), myOptions);
directionsDisplay.setMap(map);
get_distance(dest_lat,dest_lng);
}
function get_distance(dest_lat,dest_lng) {
var ori_lat = $("#latitude").val();
var ori_lng = $("#longitude").val();
var latlng = [new google.maps.LatLng(ori_lat,ori_lng)];
var dest_latlng = [new google.maps.LatLng(dest_lat,dest_lng)];
var geocoder = new google.maps.Geocoder;
var service = new google.maps.DistanceMatrixService;
service.getDistanceMatrix({
origins: latlng,
destinations: dest_latlng,
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, function(response, status) {
if (status !== google.maps.DistanceMatrixStatus.OK) {
//alert('Error was: ' + status);
} else {
//alert('Response was: ' + response.distance);
var originList = response.originAddresses;
var destinationList = response.destinationAddresses;
for (var i = 0; i < originList.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j < results.length; j++) {
var element = results[j];
var distance = element.distance.text;
var duration = element.duration.text;
var duration_bm = duration.replace("hours","jam").replace("hour","jam").replace("mins","minit");
var from = originList[i];
var to = destinationList[j];
}
}
//$("#output").html("Lokasi Asal (A) "+originList+"
Destinasi (B) "+destinationList+"
Jarak "+distance+"
Tempoh "+duration);
}
});
}
function GEOprocess(position){
$("#latitude").val((position.coords.latitude).toFixed(7));
$("#longitude").val((position.coords.longitude).toFixed(7));
GEOajax("../plugins/geolocation/geo.php?accuracy=" + position.coords.accuracy + "&latlng=" + position.coords.latitude + "," + position.coords.longitude +"&altitude="+position.coords.altitude+"&altitude_accuracy="+position.coords.altitudeAccuracy+"&heading="+position.coords.heading+"&speed="+position.coords.speed+"");
var lat = $("#latitude").val();
var long = $("#longitude").val();
showmap(lat, long, "map_box",14);
$("#show_kariah_div").load("show_kariah.php?lat="+lat+"&long="+long,function(){
});
}
function GEOdeclined(error){
$("#show_kariah_div").html("");
}
function GEOdeclined2(error){
$("#pilih_kariah_div_top").load("enter_poskod.php", function(){
Swal.fire('Organization Location Identification','Please allow your location',"info");
});
}
function GEOdeclined3(error){
$("#enter_poskod_div").load("enter_poskod.php?allow_poskod_search=1&ping=1", function(){
Swal.fire('Organization Location Identification','Please allow your location',"info");
$("#show_map_div").fadeOut();
$("#geodeclined").fadeIn();
});
}
function search_poskod(allow_poskod_search){
$("#pilih_kariah_div_top").load("enter_poskod.php?allow_poskod_search="+allow_poskod_search+"&ping=1", function(){
Swal.fire('Organization Location Identification','Please allow your location',"info");
});
}
function search_poskod_on_map(allow_poskod_search,popup=1){
$("#show_map_div").load("enter_poskod.php?allow_poskod_search="+allow_poskod_search+"&ping=0", function(){
if (popup==1){
Swal.fire('Organization Location Identification','Please allow your location',"info");
}
$("#show_map_div").addClass("container");
});
}
function search_hebahan(){
var q = $("#search_hebahan_form").serializeArray();
$("#list_hebahan_div").load("list_hebahan.php", q, function(){})
}
function GEOajax(url){
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange=updatePage;
xmlHttp.send(null);
}
function updatePage(){
if (xmlHttp.readyState==4){
var response=xmlHttp.responseText;
$("#lokasi").html(response);
}
}
function daftar(kariah_id){
location.href="daftar.php?kariah_id="+kariah_id;
}
// 20200616 - comment by izzat
//20200616 - added by izzat
// function register_form_submit(){
// var pwd1 =$("#organisasi_password").val();
// var pwd2 =$("#organisasi_password2").val();
// var org_id = $("#peserta_kariah_id").val();
// if (pwd1!=pwd2){
// Swal.fire('Error','Password Is Not The Same',"error");
// } else {
// var query = $("#register_form").serializeArray(), json={};
// $("#action_submit").load("daftar_submit_organisasi.php", query, function(data){
// if (data>5){
// Swal.fire({
// title: 'Congratulations',
// html: 'You successfully registered your organization as a Virtual member. Please check your email for more information on how you can manage your organization membership.',
// icon: 'success',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// sendmailer_data(data,'terima_kasih');
// location.href="../peserta/login.php?org_id="+org_id;
// }
// });
// /*if (organisasi_id==1){
// sendmailer_data(data,'terima_kasih_default');
// location.href="../manage/login.php";
// } else {
// sendmailer_data(data,'terima_kasih');
// location.href="../manage/login.php";
// }*/
// } else if (data<0){
// dt=new Date(-data * 1000).toLocaleString();
// resp = 'You have registered before on %s. Please login.';
// Swal.fire({
// title: 'You Have Registered',
// text: resp.replace("%s", dt),
// icon: 'error',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// location.href="../peserta/login.php?org_id="+org_id;
// }
// });
// } else if (data==2){
// Swal.fire({
// title: 'Welcome',
// text: "Anda adalah ahli maya sedia ada. Sila log masuk.",
// icon: 'success',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// sendmailer_data(data,'terima_kasih');
// location.href="../peserta/login.php?org_id="+org_id;
// }
// });
// } else if (data==3){
// Swal.fire({
// title: 'Selamat Kembali',
// text: "Anda adalah ahli maya sedia ada. Sila kemaskinikan maklumat tanggungan dan buat bayaran untuk pembaharuan keahlian",
// icon: 'success',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// sendmailer_data(data,'terima_kasih');
// location.href="../peserta/login.php?org_id="+org_id;
// }
// });
// } else if (data==4){
// Swal.fire({
// title: 'Error',
// text: 'Your Email Is Invalid',
// icon: 'error',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// // location.href="index.php";
// }
// });
// } else if (data==5){
// Swal.fire({
// title: 'Error',
// text: "Pendaftaran anda mengalami masalah teknikal!",
// icon: 'error',
// showCancelButton: false,
// confirmButtonColor: '#258'
// }).then((result) => {
// if (result.value) {
// // location.href="index.php";
// }
// });
// }
// });
// }
// }
function register_tanggungan_submit(){
//alert('submit');
var tanggungan_mykad = $("#kk_peserta_tanggungan_nokp").val();
var kk_peserta_nama_tanggungan_name = $("#kk_peserta_nama_tanggungan_name").val();
var kk_peserta_tanggungan_relationship = $('input[name="kk_peserta_tanggungan_relationship"]:checked').val();
var kk_peserta_tanggungan_sex = $('input[name="kk_peserta_tanggungan_sex"]:checked').val();
var kariah_id = $("#kk_peserta_tanggungan_kariah_id").val();
var kk_peserta_tanggungan_id = $("#kk_peserta_tanggungan_id").val();
var kk_peserta_tanggungan_notel = $("#kk_peserta_tanggungan_notel").val();
var query = $("#register_tanggungan_form").serializeArray(), json={};
query.push({"name":"kk_peserta_tanggungan_nokp", "value":tanggungan_mykad});
query.push({"name":"kk_peserta_nama_tanggungan_name", "value":kk_peserta_nama_tanggungan_name});
query.push({"name":"kk_peserta_tanggungan_relationship", "value":kk_peserta_tanggungan_relationship});
query.push({"name":"kk_peserta_tanggungan_sex", "value":kk_peserta_tanggungan_sex});
query.push({"name":"kariah_id", "value":kariah_id});
query.push({"name":"kk_peserta_tanggungan_id", "value":kk_peserta_tanggungan_id});
query.push({"name":"kk_peserta_tanggungan_notel", "value":kk_peserta_tanggungan_notel});
query.push({"name":"MM_insert_tanggungan", "value":"register_tanggungan"});
if (check_tanggungan_limit(kk_peserta_tanggungan_id,kariah_id)=="0"){ // check tanggungan limit. if 0, proceed
if (kk_peserta_tanggungan_relationship==9){
if (check_tanggungan_waris_limit(kk_peserta_tanggungan_id,kariah_id)=="0"){
var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g;
if (tanggungan_mykad.match(mykad)){
//var query = $("#register_tanggungan_form, #register_form").serializeArray(), json={};
$("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){
$("input.reset").val("");
})
} else {
Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error");
}
} else {
Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of beneficiaries that have been set by your organization.',"error");
}
} else {
var mykad = /(([[0-9]{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01]))([0-9]{2})([0-9]{4})/g;
if (tanggungan_mykad.match(mykad)){
//var query = $("#register_tanggungan_form, #register_form").serializeArray(), json={};
$("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){
$("input.reset").val("");
})
} else {
Swal.fire('Identity Card No. Format Error','Please enter the correct identity card number',"error");
}
}
} else {
Swal.fire('Already Reached the Limit of Heir Liability','You have reached the limit of the number of dependents that have been set by your organization.',"error");
}
}
function padam_tanggungan(tanggungan_id){
Swal.fire({
title: 'Are You Sure?',
text: 'This action cannot be undone',
icon: 'warning',
showCancelButton: true,
cancelButtonText: 'No',
confirmButtonText: 'Yes',
confirmButtonColor: '#258',
cancelButtonColor: '#f00'
}).then((result) => {
$("#list_tanggungan").load("daftar_tanggungan_list.php", {"MM_delete_tanggungan":"padam_tanggungan","tanggungan_id":tanggungan_id}, function(data){
})
})
}
function update_tanggungan_submit(){
var query = $("#register_tanggungan_form").serializeArray(), json={};
$("#list_tanggungan").load("daftar_tanggungan_list.php", query, function(data){
$("#register_tanggungan_div").load("register_tanggungan.php", function(){})
})
}
function kemaskini_tanggungan(tanggungan_id){
$("#register_tanggungan_div").load("register_tanggungan.php", {"MM_update_tanggungan":"update_tanggungan","tanggungan_id":tanggungan_id}, function(data){
whatsex();
})
}
function log_keluar(org_id){
$("#action_submit").load("logout.php", function(){
location.href="index.php?org_id="+org_id;
})
}
function log_masuk(org_id=null, isPopup = false){
//$("#action_submit").load("login.php", function(){
if(isPopup) login_popup(false);
else location.href="login.php?org_id="+org_id;
//})
}
function batal_tanggungan(){
$("#register_tanggungan_div").load("register_tanggungan.php", function(){});
}
function pilih_kariah(peserta_id){
location.href="pilih_kariah.php?peserta_id="+peserta_id;
}
function login_submit(org_id, fund_id=null, url=null){
var query = $("#login_form").serializeArray(), json={};
$("#action_submit").load("login_submit.php", query, function(data){
if (data==1){
if(fund_id) {
location.href="bayar_kariah_list_selected.php?kk_fund_id="+fund_id;
} else {
if (url) {
location.href=url;
} else {
location.href="akaun_saya.php?org_id="+org_id;
}
}
} else {
Swal.fire('Wrong Password Entered','You have entered an incorrect password. Please try again.',"error");
}
})
}
function login_fb(){
FB.login(function(response) {
if (response.status === 'connected') {
// Logged into your app and Facebook.
FB.api('/me', {fields: 'id,name,email,picture'}, function(response) {
if (check_fb_id(response.id)>0){
location.href="akaun_saya.php";
}else{
Swal.fire('Not registered yet','You have never registered before. Please register first.',"error");
}
});
} else {
// The person is not logged into this app or we are unable to tell.
Swal.fire('Not registered yet','You have never registered before. Please register first.',"error");
}
},{scope: 'email'});
}
function connect_fb(){
FB.login(function(response) {
if (response.status === 'connected') {
// Logged into your app and Facebook.
FB.api('/me', {fields: 'id,name,email,picture'}, function(response) {
var peserta_login_id = $("#peserta_login_id").val();
if (connect_peserta_fb(response.id,peserta_login_id,response.picture.data.url)>0){
location.href="akaun_saya.php";
}
});
} else {
// The person is not logged into this app or we are unable to tell.
}
},{scope: 'email'});
}
function sign_up_fb(){
FB.login(function(response) {
if (response.status === 'connected') {
// Logged into your app and Facebook.
FB.api('/me', {fields: 'id,name,email,picture'}, function(response) {
$("#peserta_nama").val(response.name);
$("#peserta_email").val(response.email);
$("#peserta_fb_id").val(response.id);
$("#peserta_fb_picture").val(response.picture.data.url);
$("#sign_up_result").html("
The system has obtained your information from facebook. However, you will need to complete other information. Not you?Logout of Facebook
")
$("#password_div").slideUp();
$("#peserta_mykad_password2").removeAttr("required").removeClass("required").attr("disabled",true).val("");
$("#peserta_mykad_password").removeAttr("required").removeClass("required").attr("disabled",true).val("");
//console.log(JSON.stringify(response));
//alert(JSON.stringify(response));
});
} else {
// The person is not logged into this app or we are unable to tell.
}
},{scope: 'email'});
}
function logout_fb(){
FB.logout(function(response) {
$("#sign_up_result").html("
You have been logged out. Please log in again on facebook
");
$(".form-control").val("");
animateCSS('#fb_button', 'tada', function() {
animateCSS('#fb_button', 'bounce', function() {
animateCSS('#fb_button', 'heartBeat', function() {
// Do something after animation
})
})
})
});
}
function whoami(){
FB.api('/me?fields=id,name,email,birthday', function(response) {
console.log(JSON.stringify(response));
alert(JSON.stringify(response));
});
}
function animateCSS(element, animationName, callback) {
const node = document.querySelector(element)
node.classList.add('animated', animationName)
function handleAnimationEnd() {
node.classList.remove('animated', animationName)
node.removeEventListener('animationend', handleAnimationEnd)
if (typeof callback === 'function') callback()
}
node.addEventListener('animationend', handleAnimationEnd)
}
function daftar_kariah_submit(){
var query = $("#daftar_kariah_form").serializeArray(), json={};
$("#action_submit").load("daftar_kariah.php", query, function(data){
$("#daftar_kariah_div").slideUp();
$("#action_result").html("
Thank you. We will contact you if the mosque / surau / organization you have registered has become a member of the Death Benefit System
').load(page, afterLoad),
buttons: [{
id: 'view-popup-close-2',
icon: 'fa fa-times-circle',
label: 'Close',
cssClass: 'btn-danger float-left',
autospin: true,
action: function(dialog){
dialog.close();
}
}],
draggable: true,
onshown: function(){
$(document).off('focusin.modal');
$('.modal-content').css('margin','5px 0');
$('.modal-content').css('max-height','100vh');
$('.modal-body').css('max-height','70vh');
$('.modal-body').css("overflow-y","scroll");
$('[data-toggle="tooltip"]').tooltip();
},
}).setSize(modalSize ?? BootstrapDialog.SIZE_WIDE);
dialog.getModalHeader().css('background-color', '#258');
}
function check_payment_is_allowed(fund_id, kariah_id){
var return_value = $.ajax({
url: 'check_payment_is_allowed.php',
data: {"fund_id":fund_id,"kariah_id":kariah_id},
async: false
}).responseText;
return return_value;
}
function check_payment_is_allowed_for_peserta(fund_id, kariah_id, peserta_id){
var return_value = $.ajax({
url: 'check_payment_is_allowed_for_peserta.php',
data: {"fund_id":fund_id,"kariah_id":kariah_id,"peserta_id":peserta_id},
async: false
}).responseText;
return return_value;
}
function blinkElement(selector) {
$(selector).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
}
function reloadScript(url) {
const oldScript = document.querySelector(`script[src="${url}"]`);
if (oldScript) oldScript.remove(); // Remove the existing script
// Create a new script element with a cache-busting parameter
const newScript = document.createElement("script");
newScript.src = `${url}?t=${new Date().getTime()}`; // Cache-busting query parameter
document.head.appendChild(newScript);
}
// for use with custom/php/custom.php setup_autocomplete_ajax()
$(document).ready(function() {
const MIN_CHARACTERS = 3; // Minimum characters before triggering AJAX
const DEBOUNCE_DELAY = 300; // milliseconds
// Function to escape HTML to prevent XSS
function escapeHtml(text) {
return $('
').text(text).html();
}
// Function to display error messages
function showErrorMessage(input, message) {
// Remove existing message if any
input.next('.error-message').remove();
// Append a new message
input.after(`${message}`);
}
// Function to remove error messages
function removeErrorMessage(input) {
input.next('.error-message').remove();
}
// Initialize autocomplete for all inputs with class 'autocomplete-ajax'
$('.autocomplete-ajax').each(function() {
const input = $(this);
const datalistId = input.attr('list');
const datalist = $('#' + datalistId);
const ajaxUrl = input.data('ajax-url');
const strict = input.data('strict') === '1';
const hiddenInputSelector = input.data('hidden-input') || null;
const hiddenInput = hiddenInputSelector ? $(hiddenInputSelector) : null;
const noRepeatValues = input.data('norepeatvalues') || null; // Note: data-noRepeatValues becomes data-norepeatvalues in jQuery
let debounceTimeout = null;
let isSelecting = false; // Flag to indicate selection from datalist
// Function to fetch and populate datalist
function fetchAutocompleteSuggestions(query, excludeValues=[]) {
$.ajax({
url: ajaxUrl,
method: 'POST',
data: {
search_str: query,
exclude_values: excludeValues // Send values to exclude
},
dataType: 'json',
success: function(data) {
datalist.empty(); // Clear previous options
removeErrorMessage(input); // Remove any existing error message
if (data.error) {
console.error('Autocomplete Error:', data.error);
return;
}
const entries = Object.entries(data);
if (entries.length === 0) {
// Optionally, handle no results without adding an option
// For now, do nothing
return;
}
entries.forEach(function([key, value]) {
const escapedValue = escapeHtml(value);
datalist.append(``);
});
},
error: function(xhr, status, error) {
console.error('AJAX Error:', status, error);
}
});
}
// Function to get all selected values in the same group
function getSelectedValuesInGroup(group) {
if (!group) return [];
const selectedValues = [];
$(`.autocomplete-ajax[data-norepeatvalues="${group}"]`).each(function() {
const val = $(this).val();
if (val) selectedValues.push(val);
});
return selectedValues;
}
// Event listener for input events with debouncing
input.on('input', function() {
if (isSelecting) {
// Skip AJAX call if the input change is due to a selection
isSelecting = false;
return;
}
const query = $(this).val();
// Get selected values in the same group to exclude from suggestions
const excludeValues = noRepeatValues ? getSelectedValuesInGroup(noRepeatValues).filter(v => v !== query) : [];
// Clear any existing debounce timeout
if (debounceTimeout) {
clearTimeout(debounceTimeout);
}
// Debounce the AJAX request
debounceTimeout = setTimeout(function() {
if (query.length >= MIN_CHARACTERS) {
fetchAutocompleteSuggestions(query, excludeValues);
} else {
datalist.empty(); // Clear datalist if query is too short
removeErrorMessage(input); // Remove any existing error message
}
}, DEBOUNCE_DELAY);
});
// Event listener for selection from datalist
input.on('change', function() {
const selectedValue = $(this).val();
let matched = false;
let selectedId = null;
// Iterate through datalist options to find a match
datalist.find('option').each(function() {
if ($(this).val() === selectedValue) {
matched = true;
if (hiddenInput) {
selectedId = $(this).attr('data-id');
}
return false; // Break loop
}
});
if (matched) {
if (hiddenInput && selectedId) {
hiddenInput.val(selectedId);
}
removeErrorMessage(input); // Remove any existing error message
} else {
if (strict) {
// Check if the value is already selected in the same group
if (noRepeatValues) {
const duplicate = getSelectedValuesInGroup(noRepeatValues).includes(selectedValue);
if (duplicate) {
// Clear input and hidden field if strict and duplicate found
input.val('');
if (hiddenInput) {
hiddenInput.val('');
}
showErrorMessage(input, 'Cannot pick the same value.');
return;
}
}
// Clear input and hidden field if strict and no match
input.val('');
if (hiddenInput) {
hiddenInput.val('');
}
showErrorMessage(input, 'Please select a valid option from the list.');
} else {
if (hiddenInput) {
hiddenInput.val('');
}
}
}
// Set the selection flag to prevent the next input event from triggering AJAX
if (matched) {
isSelecting = true;
}
});
// Optional: Handle form submission to ensure valid selection if strict
if (strict) {
input.closest('form').on('submit', function(e) {
const selectedValue = input.val();
let matched = false;
datalist.find('option').each(function() {
if ($(this).val() === selectedValue) {
matched = true;
return false; // Break loop
}
});
if (!matched) {
// Prevent form submission and notify user
e.preventDefault();
alert('Please select a valid option from the list.');
}
});
}
});
});
function view_session(training_student_id, training_program_id) {
if (!training_student_id || !training_program_id) {
BootstrapDialog.alert('Invalid request. Missing student or training program ID.');
return;
}
lowerDialogInstance = BootstrapDialog.show({
title: 'Training Modules',
size: BootstrapDialog.SIZE_WIDE,
message: function(dialog) {
var $message = $('