Commit 03fcc196 authored by Deep Dey's avatar Deep Dey

feat: add success page on form submit

parent 685ba1d6
...@@ -288,7 +288,10 @@ ...@@ -288,7 +288,10 @@
<!-- end of image section --> <!-- end of image section -->
<div class="form-btn"> <div class="form-btn">
<button type="submit" class="btn btn-sumbit">Submit</button> <button type="submit" class="btn btn-sumbit" id="btn-sumbit">
<div class="loader"></div>
<div class="btn-text">Submit</span>
</button>
</div> </div>
</form> </form>
</div> </div>
......
...@@ -181,7 +181,11 @@ $(document).ready(function () { ...@@ -181,7 +181,11 @@ $(document).ready(function () {
}, },
submitHandler: function (form) { submitHandler: function (form) {
var formData = new FormData(form); var formData = new FormData(form);
console.log(formData.get('candidateImage')); let jsonData = {};
$('.loader').css('display', 'inline-block');
$('.btn-text').css('display', 'none');
$('#btn-sumbit').prop('disabled', true);
$.ajax({ $.ajax({
// TODO: move the url to a constant file // TODO: move the url to a constant file
...@@ -191,9 +195,19 @@ $(document).ready(function () { ...@@ -191,9 +195,19 @@ $(document).ready(function () {
processData: false, processData: false,
contentType: false, contentType: false,
success: function (response) { success: function (response) {
console.log('Success:', response);
formData.forEach((value, key) => {
jsonData[key] = value;
});
sessionStorage.setItem('userData', JSON.stringify(jsonData));
window.location.href = 'success.html';
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
$('.loader').css('display', 'none');
$('.btn-text').css('display', 'inline-block');
$('#btn-sumbit').prop('disabled', false);
if (xhr.responseText) { if (xhr.responseText) {
var errorMessage = JSON.parse(xhr.responseText).message; var errorMessage = JSON.parse(xhr.responseText).message;
console.error('Server Response:', errorMessage); console.error('Server Response:', errorMessage);
......
...@@ -110,7 +110,9 @@ body { ...@@ -110,7 +110,9 @@ body {
} }
.btn { .btn {
display: inline-block; display: flex;
justify-content: center;
align-items: center;
font-weight: 400; font-weight: 400;
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
...@@ -142,7 +144,7 @@ body { ...@@ -142,7 +144,7 @@ body {
border-color: #0062cc; border-color: #0062cc;
} }
.form-image-group{ .form-image-group {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
...@@ -150,7 +152,7 @@ body { ...@@ -150,7 +152,7 @@ body {
margin-top: 30px; margin-top: 30px;
} }
.form-image-group .form-group{ .form-image-group .form-group {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
...@@ -166,3 +168,23 @@ body { ...@@ -166,3 +168,23 @@ body {
margin: 10px; margin: 10px;
object-fit: cover; object-fit: cover;
} }
.loader {
display: none;
border: 5px solid #f3f3f3;
border-top: 5px solid #3498db;
border-radius: 50%;
width: 16px;
height: 16px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>La Martiniere for Girls - Proof of Delivery</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 50px auto;
padding: 20px;
border-radius: 10px;
}
.header {
text-align: center;
}
.header h1 {
margin-bottom: 5px;
}
.proof-of-delivery {
text-align: center;
margin: 20px 0;
padding: 10px;
background-color: #d9edf7;
color: #31708f;
border: 1px solid #bce8f1;
border-radius: 5px;
}
.email {
color: green;
}
.details {
margin: 20px 0;
}
.details p {
margin: 5px 0;
}
.details span {
font-weight: bold;
}
.footer {
margin: 20px 0;
text-align: center;
font-size: 12px;
color: #555;
}
.social-links {
text-align: center;
margin: 20px 0;
}
.social-links a {
margin: 0 10px;
text-decoration: none;
color: #007bff;
}
.social-links a:hover {
text-decoration: underline;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
<div class="header">
<img src="https://i0.wp.com/lamartiniere.co/wp-content/uploads/2020/10/cropped-lmbb-logo-site-logo.png?w=240&ssl=1"
alt="Proof of Delivery" height="80px">
<h2 id="school"></h2>
</div>
<div class="proof-of-delivery">
<p>Thank you. Your application has been received.</p>
</div>
<div class="details" id="details"></div>
<div class="footer">
<p>Please quote the reference <span class="email">piklughosh01@gmail.com</span> for further correspondence
until such time the admission procedure is under way.</p>
</div>
</div>
<script>
$(document).ready(function () {
// Retrieve the JSON string from session storage
var jsonData = sessionStorage.getItem('userData');
// Parse the JSON string back to an object
if (jsonData) {
var userObject = JSON.parse(jsonData);
// Display the data
var userDataHtml = `
<p><span>CATEGORY:</span> ${userObject.category}</p>
<p><span>CLASS:</span> ${userObject.admissionClass}</p>
<p><span>NAME OF CANDIDATE:</span> ${userObject.fullName}</p>
<p><span>DATE OF BIRTH:</span> ${userObject.dateOfBirth}</p>
<p><span>FATHER'S NAME:</span> ${userObject.fatherName}</p>
<p><span>FATHER'S NAME:</span> ${userObject.motherName}</p>
`;
$('#details').html(userDataHtml);
$('#school').html(userObject.school);
} else {
$('#details').html('<p>No user data found.</p>');
}
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment