CARVIEW |
Select Language
HTTP/2 200
date: Fri, 10 Oct 2025 22:43:56 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=3be249fba7f2f8e9725c2a2ff07e5c20f757c4ce3c75997289872e453290f7eca%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22uDA6FPvrmEwNcs-DHCY0ND8X0_89BhYM%22%3B%7D; HttpOnly; Path=/
cf-ray: 98c9a3b49d695917-BLR
Select2 Independ Search Without Ajax - Pastebin.com
SHARE
TWEET

Select2 Independ Search Without Ajax
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $('employee_id').select2();
- // PHP-generated employee data
- const employees = {!! $employeeDataJson !!};
- // Function to filter and populate employee dropdown
- function filterEmployees() {
- const type = $('#emp_type').val();
- const department = $('#department').val();
- let filteredEmployees = employees;
- if(type){
- filteredEmployees = filteredEmployees.filter(employee => employee.employee_type === type);
- }
- if(department){
- // Single Department
- filteredEmployees = filteredEmployees.filter(employee => employee.department_type === department);
- // Multiple Department
- // var departments = [3,5,6,78,41]; array
- // filteredEmployees = filteredEmployees.filter(employee =>
- // departments.includes(employee.department_type) // Interger
- // departments.includes(employee.department_type.toString()) // String
- // );
- }
- // Clear current options
- $('#employee_id').empty().append('<option value="">Select Employee</option>');
- // Add filtered options
- filteredEmployees.forEach(employee => {
- // $('#employee_id').append(new Option(employee.name, employee.id));
- var newOption = $('<option>');
- newOption.attr('value', employee.id); // Set the value attribute
- newOption.text(employee.name); // Set the text content
- newOption.attr('data-department_type', employee.department_type);
- newOption.attr('data-employee_type', employee.employee_type);
- newOption.attr('data-shift_start', employee.shift_start);
- newOption.attr('data-shift_end', employee.shift_end);
- $('#employee_id').append(newOption);
- });
- // Refresh Select2
- $('#employee_id').trigger('change');
- }
- // Event listeners
- $('#emp_type, #department').on('change', filterEmployees);
- // Initial population
- filterEmployees();
- </script>
Tags:
Select2 Local Search
Advertisement
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ D
JavaScript | 6 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 12 sec ago | 0.10 KB
-
⭐✅ Swapzone Glitch ✅ Working⭐⭐⭐ G
JavaScript | 13 sec ago | 0.24 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ J
JavaScript | 24 sec ago | 0.24 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 25 sec ago | 0.10 KB
-
⭐⭐Exchange Exploit⭐⭐ E
JavaScript | 35 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 38 sec ago | 0.10 KB
-
⭐✅ Swapzone Glitch ✅ Working⭐⭐⭐ 5
JavaScript | 44 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand