/
home
/
u764571690
/
domains
/
savitrfoundation.com
/
public_html
/
admin
/
pages
/
/home/u764571690/domains/savitrfoundation.com/public_html/admin/pages
mkdir
upload
Name
Size
Mode
Actions
add_admission.php
11418
0644
edit
dl
rm
add_blog.php
3882
0644
edit
dl
rm
add_campaign.php
4326
0644
edit
dl
rm
add_certificate.php
3756
0644
edit
dl
rm
add_college.php
5839
0644
edit
dl
rm
add_college_courses.php
6366
0644
edit
dl
rm
add_content.php
5380
0644
edit
dl
rm
add_course.php
3249
0644
edit
dl
rm
add_expense.php
3847
0644
edit
dl
rm
add_expenses.php
4373
0644
edit
dl
rm
add_fees.php
4576
0644
edit
dl
rm
add_gallery.php
4054
0644
edit
dl
rm
add_intern.php
29360
0644
edit
dl
rm
add_internship.php
6273
0644
edit
dl
rm
add_internship_gallery.php
5994
0644
edit
dl
rm
add_intern_blog.php
7234
0644
edit
dl
rm
add_receive.php
3836
0644
edit
dl
rm
add_service.php
2773
0644
edit
dl
rm
add_specialisation.php
3713
0644
edit
dl
rm
add_stream.php
2405
0644
edit
dl
rm
admission_report.php
10404
0644
edit
dl
rm
appointment_list.php
2138
0644
edit
dl
rm
campaign_list.php
1733
0644
edit
dl
rm
campaign_update.php
3882
0644
edit
dl
rm
certificate_edit.php
3586
0644
edit
dl
rm
contact_form.php
1972
0644
edit
dl
rm
contact_us.php
2009
0644
edit
dl
rm
content_pages.php
3154
0644
edit
dl
rm
edit_add.php
3836
0644
edit
dl
rm
edit_admission.php
8973
0644
edit
dl
rm
edit_blog.php
3913
0644
edit
dl
rm
edit_campaign.php
6227
0644
edit
dl
rm
edit_college.php
6421
0644
edit
dl
rm
edit_college_courses.php
7991
0644
edit
dl
rm
edit_course.php
3661
0644
edit
dl
rm
edit_courses_content.php
3623
0644
edit
dl
rm
edit_donation.php
3588
0644
edit
dl
rm
edit_expense.php
3865
0644
edit
dl
rm
edit_expenses.php
3911
0644
edit
dl
rm
edit_fees.php
3357
0644
edit
dl
rm
edit_fees_type.php
2850
0644
edit
dl
rm
edit_gallery.php
4658
0644
edit
dl
rm
edit_intern.php
35116
0644
edit
dl
rm
edit_internship.php
7595
0644
edit
dl
rm
edit_internship_gallery.php
7328
0644
edit
dl
rm
edit_intern_blog.php
8254
0644
edit
dl
rm
edit_invoice.php
4916
0644
edit
dl
rm
edit_report.php
19
0644
edit
dl
rm
edit_service.php
3127
0644
edit
dl
rm
edit_specialisation.php
4712
0644
edit
dl
rm
edit_stream.php
2783
0644
edit
dl
rm
edit_student_list.php
0
0644
edit
dl
rm
edit_user.php
3547
0644
edit
dl
rm
edit_volunteer.php
4110
0644
edit
dl
rm
enquiry.php
3070
0644
edit
dl
rm
fees_type.php
3127
0644
edit
dl
rm
foot.php
6385
0644
edit
dl
rm
gallery.php
3996
0644
edit
dl
rm
gallery_edit.php
3460
0644
edit
dl
rm
gallery_view.php
1734
0644
edit
dl
rm
get.php
28
0644
edit
dl
rm
head.php
13417
0644
edit
dl
rm
home.php
4504
0644
edit
dl
rm
home_enquiry.php
2024
0644
edit
dl
rm
important.php
15460
0644
edit
dl
rm
logout.php
60
0644
edit
dl
rm
postAcceptor.php
2170
0644
edit
dl
rm
student_list.php
9476
0644
edit
dl
rm
view_admission.php
2875
0644
edit
dl
rm
view_blog.php
4991
0644
edit
dl
rm
view_campaign.php
5875
0644
edit
dl
rm
view_certificate.php
1678
0644
edit
dl
rm
view_college.php
3611
0644
edit
dl
rm
view_college_courses.php
4203
0644
edit
dl
rm
view_course.php
3579
0644
edit
dl
rm
view_donation.php
1817
0644
edit
dl
rm
view_expense.php
1897
0644
edit
dl
rm
view_expenses.php
1848
0644
edit
dl
rm
view_fees.php
1825
0644
edit
dl
rm
view_fees_type.php
1679
0644
edit
dl
rm
view_gallery.php
4592
0644
edit
dl
rm
view_interns.php
4184
0644
edit
dl
rm
view_internship.php
4092
0644
edit
dl
rm
view_internship_gallery.php
5239
0644
edit
dl
rm
view_intern_blog.php
5330
0644
edit
dl
rm
view_invoice.php
15361
0644
edit
dl
rm
view_invoice2.php
1898
0644
edit
dl
rm
view_message.php
2367
0644
edit
dl
rm
view_report.php
9643
0644
edit
dl
rm
view_service.php
1691
0644
edit
dl
rm
view_specialisation.php
3605
0644
edit
dl
rm
view_stream.php
3579
0644
edit
dl
rm
view_user.php
3894
0644
edit
dl
rm
view_user2.php
1809
0644
edit
dl
rm
volunteer.php
2110
0644
edit
dl
rm
Edit:
/home/u764571690/domains/savitrfoundation.com/public_html/admin/pages/edit_intern.php
(35116B)
<style> .content-wrapper>.content { padding-top: 24px; } .preview_image { display: block; margin: auto !important; max-width: 100%; height: auto; border: 1px solid #ddd; border-radius: 5px; padding: 4px; background: #fff; cursor: pointer; } .preview_image:hover { opacity: 0.8; } .form-section { margin-bottom: 30px; padding: 20px; border: 1px solid #ddd; border-radius: 5px; background-color: #f9f9f9; } .section-title { margin-top: 0; padding-bottom: 10px; border-bottom: 1px solid #eee; color: #333; } /* Popup modal styles */ .modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.9); } .modal-content { margin: auto; display: block; width: 80%; max-width: 700px; max-height: 80%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .modal-content { animation-name: zoom; animation-duration: 0.6s; } @keyframes zoom { from {transform: scale(0.1)} to {transform: scale(1)} } .close { position: absolute; top: 15px; right: 35px; color: #f1f1f1; font-size: 40px; font-weight: bold; cursor: pointer; z-index: 1001; } .close:hover, .close:focus { color: #bbb; } .modal-caption { text-align: center; color: #ccc; padding: 10px; position: absolute; width: 100%; bottom: 0; } </style> <!-- Main content --> <?php date_default_timezone_set('Asia/Kolkata'); // Get intern ID from URL using a more reliable method // The URL will be something like /interns/edit_intern/1 $path = trim($_SERVER['REQUEST_URI'], '/'); $path_parts = explode('/', $path); // Find the edit_intern part and get the ID after it $intern_id = 0; for ($i = 0; $i < count($path_parts); $i++) { if ($path_parts[$i] == 'edit_intern' && isset($path_parts[$i + 1])) { $intern_id = intval($path_parts[$i + 1]); break; } } // Validate that we have a numeric ID if ($intern_id <= 0) { echo "<div class='alert alert-danger'>Invalid intern ID</div>"; exit; } // Ensure we have a database connection if (!isset($con) || !$con) { // Try to get the connection from the function file include_once $_SERVER['DOCUMENT_ROOT'].'/functions/function.php'; $con = connection(); } // Fetch the intern data $intern = array(); if ($intern_id > 0 && $con) { $result = mysqli_query($con, "SELECT * FROM interns WHERE id = $intern_id"); $intern = mysqli_fetch_assoc($result); } if (!$intern) { echo "<div class='alert alert-danger'>Intern not found. ID: $intern_id</div>"; exit; } ?> <div class="content-wrapper"> <section class="content-header"> <div class="container-fluid"> <div class="row mb-2"> <div class="col-sm-6"> <h4>Edit Intern</h4> </div> <div class="col-sm-6"> <ol class="breadcrumb float-sm-right"> <li class="breadcrumb-item"><a href="/">Home</a></li> <li class="breadcrumb-item"><a href="/interns/view_interns">View Interns</a></li> <li class="breadcrumb-item active">Edit Intern</li> </ol> </div> </div> </div><!-- /.container-fluid --> </section> <section class="content"> <div class="row"> <div class="col-md-12"> <!-- general form elements disabled --> <div id="web_settings" class="card card-primary"> <div class="card-header bg-info"> <h3 class="card-title">Intern Details</h3> </div> <!-- /.card-header --> <div class="card-body"> <div id="msgbox" class="alert alert-success d-none">Intern Updated Successfully</div> <form name="edit_intern" method="post" id="edit_intern" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $intern['id']; ?>"> <!-- Personal Details Section --> <div class="form-section"> <h4 class="section-title">Personal Details</h4> <div class="row"> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Application ID</label> <input type="text" class="form-control" name="application_id" id="application_id" placeholder="Enter Application ID" value="<?php echo htmlspecialchars($intern['application_id'] ?? ''); ?>">> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Full Name *</label> <input type="text" class="form-control" name="full_name" id="full_name" placeholder="Enter Full Name" value="<?php echo htmlspecialchars($intern['full_name'] ?? ''); ?>" required> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Father's Name</label> <input type="text" class="form-control" name="father_name" id="father_name" placeholder="Enter Father's Name" value="<?php echo htmlspecialchars($intern['father_name'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Mother's Name</label> <input type="text" class="form-control" name="mother_name" id="mother_name" placeholder="Enter Mother's Name" value="<?php echo htmlspecialchars($intern['mother_name'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Date of Birth</label> <input type="date" class="form-control" name="dob" id="dob" value="<?php echo $intern['dob']; ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Gender</label> <select class="form-control" name="gender" id="gender"> <option value="">Select Gender</option> <option value="Male" <?php echo ($intern['gender'] == 'Male') ? 'selected' : ''; ?>>Male</option> <option value="Female" <?php echo ($intern['gender'] == 'Female') ? 'selected' : ''; ?>>Female</option> <option value="Other" <?php echo ($intern['gender'] == 'Other') ? 'selected' : ''; ?>>Other</option> </select> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Contact Number</label> <input type="text" class="form-control" name="contact_number" id="contact_number" placeholder="Enter Contact Number" value="<?php echo htmlspecialchars($intern['contact_number'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Email</label> <input type="email" class="form-control" name="email" id="email" placeholder="Enter Email" value="<?php echo htmlspecialchars($intern['email'] ?? ''); ?>"> </div> </div> <div class="col-sm-12"> <div class="form-group ctrl_box"> <label>Address</label> <textarea class="form-control" name="address" id="address" placeholder="Enter Address"><?php echo htmlspecialchars($intern['address'] ?? ''); ?></textarea> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Photo</label> <div class="custom-file ctrl_box"> <input type="file" name="photo" id="photo" onchange="loadLogo(this);" class="form-control custom-file-input" accept="image/*"> <label class="custom-file-label" for="photo">Choose file</label> </div> </div> </div> <div class="col-sm-6"> <div class="form-group" style="text-align: center;"> <?php $photoPath = '/uploads/interns/'.$intern['application_id'].'/'.$intern['photo']; if (!empty($intern['photo']) && file_exists($_SERVER['DOCUMENT_ROOT'].$photoPath)): ?> <img class="preview_image img-fluid" id="logo" src="<?= $photoPath; ?>" alt="Current Photo" style="max-height: 100px; max-width: 100px;" data-fullsrc="<?= $photoPath; ?>"> <?php else: ?> <img class="preview_image img-fluid" id="logo" src="/admin/assets/img/noimg.png" alt="Photo Preview" style="max-height: 100px; max-width: 100px;"> <?php endif; ?> </div> </div> </div> </div> <!-- Academic Details Section --> <div class="form-section"> <h4 class="section-title">Academic Details</h4> <div class="row"> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>College Name</label> <input type="text" class="form-control" name="college_name" id="college_name" placeholder="Enter College Name" value="<?php echo htmlspecialchars($intern['college_name'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Course Name</label> <input type="text" class="form-control" name="course_name" id="course_name" placeholder="Enter Course Name" value="<?php echo htmlspecialchars($intern['course_name'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Department</label> <input type="text" class="form-control" name="department" id="department" placeholder="Enter Department" value="<?php echo htmlspecialchars($intern['department'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Year/Semester</label> <input type="text" class="form-control" name="year_semester" id="year_semester" placeholder="Enter Year/Semester" value="<?php echo htmlspecialchars($intern['year_semester'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Enrollment Number</label> <input type="text" class="form-control" name="enrollment_no" id="enrollment_no" placeholder="Enter Enrollment Number" value="<?php echo htmlspecialchars($intern['enrollment_no'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Division/Batch</label> <input type="text" class="form-control" name="division_batch" id="division_batch" placeholder="Enter Division/Batch" value="<?php echo htmlspecialchars($intern['division_batch'] ?? ''); ?>"> </div> </div> </div> </div> <!-- Internship Details Section --> <div class="form-section"> <h4 class="section-title">Internship Details</h4> <div class="row"> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Internship Type</label> <select class="form-control" name="internship_type" id="internship_type"> <option value="Online" <?php echo ($intern['internship_type'] == 'Online') ? 'selected' : ''; ?>>Online</option> <option value="Offline" <?php echo ($intern['internship_type'] == 'Offline') ? 'selected' : ''; ?>>Offline</option> <option value="Hybrid" <?php echo ($intern['internship_type'] == 'Hybrid') ? 'selected' : ''; ?>>Hybrid</option> </select> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Domain</label> <input type="text" class="form-control" name="domain" id="domain" placeholder="Enter Domain" value="<?php echo htmlspecialchars($intern['domain'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Duration</label> <input type="text" class="form-control" name="duration" id="duration" placeholder="Enter Duration" value="<?php echo htmlspecialchars($intern['duration'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Mentor Name</label> <input type="text" class="form-control" name="mentor_name" id="mentor_name" placeholder="Enter Mentor Name" value="<?php echo htmlspecialchars($intern['mentor_name'] ?? ''); ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Start Date</label> <input type="date" class="form-control" name="start_date" id="start_date" value="<?php echo $intern['start_date']; ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>End Date</label> <input type="date" class="form-control" name="end_date" id="end_date" value="<?php echo $intern['end_date']; ?>"> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Location</label> <input type="text" class="form-control" name="location" id="location" placeholder="Enter Location" value="<?php echo htmlspecialchars($intern['location'] ?? ''); ?>"> </div> </div> </div> </div> <!-- Document Uploads Section --> <div class="form-section"> <h4 class="section-title">Document Uploads</h4> <div class="row"> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>College ID Card</label> <div class="custom-file ctrl_box"> <input type="file" name="college_id_card" id="college_id_card" class="form-control custom-file-input" accept="image/*,application/pdf"> <label class="custom-file-label" for="college_id_card">Choose file</label> </div> <?php $collegeIdPath = '/uploads/interns/'.$intern['application_id'].'/'.$intern['college_id_card']; if (!empty($intern['college_id_card']) && file_exists($_SERVER['DOCUMENT_ROOT'].$collegeIdPath)): ?> <small>Current file: <?php echo htmlspecialchars($intern['college_id_card'] ?? ''); ?></small> <?php $file_ext = strtolower(pathinfo($intern['college_id_card'], PATHINFO_EXTENSION)); if (in_array($file_ext, ['jpg', 'jpeg', 'png', 'gif'])): ?> <br><img class="preview_image" src="<?= $collegeIdPath; ?>" alt="College ID" style="max-width: 100px; max-height: 100px; margin-top: 10px;" data-fullsrc="<?= $collegeIdPath; ?>"> <?php else: ?> <br><a href="<?= $collegeIdPath; ?>" target="_blank">View Document</a> <?php endif; ?> <?php endif; ?> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Aadhar Front Photo</label> <div class="custom-file ctrl_box"> <input type="file" name="aadhar_card" id="aadhar_card" class="form-control custom-file-input" accept="image/*,application/pdf"> <label class="custom-file-label" for="aadhar_card">Choose file</label> </div> <?php $aadharPath = '/uploads/interns/'.$intern['application_id'].'/'.$intern['aadhar_front_photo']; if (!empty($intern['aadhar_front_photo']) && file_exists($_SERVER['DOCUMENT_ROOT'].$aadharPath)): ?> <small>Current file: <?php echo htmlspecialchars($intern['aadhar_front_photo'] ?? ''); ?></small> <?php $file_ext = strtolower(pathinfo($intern['aadhar_front_photo'], PATHINFO_EXTENSION)); if (in_array($file_ext, ['jpg', 'jpeg', 'png', 'gif'])): ?> <br><img class="preview_image" src="<?= $aadharPath; ?>" alt="Aadhar Front Photo" style="max-width: 100px; max-height: 100px; margin-top: 10px;" data-fullsrc="<?= $aadharPath; ?>"> <?php else: ?> <br><a href="<?= $aadharPath; ?>" target="_blank">View Document</a> <?php endif; ?> <?php endif; ?> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Resume</label> <div class="custom-file ctrl_box"> <input type="file" name="resume" id="resume" class="form-control custom-file-input" accept="application/pdf,.doc,.docx"> <label class="custom-file-label" for="resume">Choose file</label> </div> <?php $resumePath = '/uploads/interns/'.$intern['application_id'].'/'.$intern['resume']; if (!empty($intern['resume']) && file_exists($_SERVER['DOCUMENT_ROOT'].$resumePath)): ?> <small>Current file: <?php echo htmlspecialchars($intern['resume'] ?? ''); ?></small> <br><a href="<?= $resumePath; ?>" target="_blank">View Document</a> <?php endif; ?> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Aadhar Back Photo</label> <div class="custom-file ctrl_box"> <input type="file" name="photo_upload" id="photo_upload" class="form-control custom-file-input" accept="image/*"> <label class="custom-file-label" for="photo_upload">Choose file</label> </div> <?php $photoUploadPath = '/uploads/interns/'.$intern['application_id'].'/'.$intern['aadhar_back_photo']; if (!empty($intern['aadhar_back_photo']) && file_exists($_SERVER['DOCUMENT_ROOT'].$photoUploadPath)): ?> <small>Current file: <?php echo htmlspecialchars($intern['aadhar_back_photo'] ?? ''); ?></small> <?php $file_ext = strtolower(pathinfo($intern['aadhar_back_photo'], PATHINFO_EXTENSION)); if (in_array($file_ext, ['jpg', 'jpeg', 'png', 'gif'])): ?> <br><img class="preview_image" src="<?= $photoUploadPath; ?>" alt="Aadhar Back Photo" style="max-width: 100px; max-height: 100px; margin-top: 10px;" data-fullsrc="<?= $photoUploadPath; ?>"> <?php else: ?> <br><a href="<?= $photoUploadPath; ?>" target="_blank">View Document</a> <?php endif; ?> <?php endif; ?> </div> </div> </div> </div> <!-- Admin/System Fields Section --> <div class="form-section"> <h4 class="section-title">Admin/System Fields</h4> <div class="row"> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Approval Status</label> <select class="form-control" name="approval_status" id="approval_status"> <option value="Pending" <?php echo ($intern['approval_status'] == 'Pending') ? 'selected' : ''; ?>>Pending</option> <option value="Approved" <?php echo ($intern['approval_status'] == 'Approved') ? 'selected' : ''; ?>>Approved</option> <option value="Rejected" <?php echo ($intern['approval_status'] == 'Rejected') ? 'selected' : ''; ?>>Rejected</option> </select> </div> </div> <div class="col-sm-6"> <div class="form-group ctrl_box"> <label>Certificate Status</label> <select class="form-control" name="certificate_status" id="certificate_status"> <option value="Not Issued" <?php echo ($intern['certificate_status'] == 'Not Issued') ? 'selected' : ''; ?>>Not Issued</option> <option value="Issued" <?php echo ($intern['certificate_status'] == 'Issued') ? 'selected' : ''; ?>>Issued</option> </select> </div> </div> <div class="col-sm-12"> <div class="form-group ctrl_box"> <label>Completion Report</label> <textarea class="form-control" name="completion_report" id="completion_report" placeholder="Enter Completion Report"><?php echo htmlspecialchars($intern['completion_report'] ?? ''); ?></textarea> </div> </div> </div> </div> <div class="row"> <div class="col-sm-12"> <div class="form-group"> <input type="submit" name="edit_intern" class="btn btn-info btn-block" value="Update Intern" /> </div> </div> </div> </form> </div> <!-- /.card-body --> </div> <!-- /.card --> </div> </div> </section> </div> <script> function loadLogo(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $('#logo') .attr('src', e.target.result) .width(100) .height(100); }; reader.readAsDataURL(input.files[0]); } } $(document).ready(function() { // Update file input labels when files are selected $('.custom-file-input').on('change', function() { var fileName = $(this).val().split('\\').pop(); $(this).next('.custom-file-label').addClass("selected").html(fileName); }); // Handle form submission for editing intern $('#edit_intern').on('submit', function(e) { e.preventDefault(); var formData = new FormData(this); $.ajax({ url: '/admin/ajax/action/edit_intern_ajax.php', type: 'POST', data: formData, contentType: false, processData: false, success: function(response) { if (response == 'success') { $('#msgbox').removeClass('d-none').addClass('alert-success').text('Intern Updated Successfully'); } else { $('#msgbox').removeClass('d-none').addClass('alert-danger').text('Error: ' + response); } }, error: function() { $('#msgbox').removeClass('d-none').addClass('alert-danger').text('Error occurred while updating intern'); } }); }); }); </script> <!-- Image Modal --> <div id="imageModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImage"> <div class="modal-caption" id="modalCaption"></div> </div> <script> // Image popup functionality $(document).ready(function() { // Add click event to all preview images $('.preview_image').on('click', function() { var imgSrc = $(this).attr('src'); var altText = $(this).attr('alt'); $('#modalImage').attr('src', imgSrc); $('#modalCaption').text(altText); $('#imageModal').css('display', 'block'); }); // Close modal when clicking on X $('.close').on('click', function() { $('#imageModal').css('display', 'none'); }); // Close modal when clicking outside the image $('#imageModal').on('click', function(event) { if (event.target.id === 'imageModal') { $('#imageModal').css('display', 'none'); } }); // Close modal with Escape key $(document).keyup(function(e) { if (e.key === "Escape") { $('#imageModal').css('display', 'none'); } }); }); </script>
Save
cmd:
run