-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
75 lines (63 loc) · 3.21 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Get references to the district and college dropdowns
const districtDropdown = document.getElementById('districts');
const collegeDropdown = document.getElementById('colleges');
// Function to populate the colleges dropdown based on the selected district
function populateCollegesDropdown() {
// Get the selected district
const selectedDistrict = districtDropdown.value;
// Clear previous options in the colleges dropdown
collegeDropdown.innerHTML = '';
// Populate the colleges dropdown with options based on the selected district
if (selectedDistrict !== '') {
const colleges = districtData[selectedDistrict];
colleges.forEach(college => {
const option = document.createElement('option');
option.text = college;
option.value = college;
collegeDropdown.appendChild(option);
});
} else {
// If no district is selected, display a default option
const option = document.createElement('option');
option.text = 'Select College';
option.value = '';
collegeDropdown.appendChild(option);
}
}
// Add an event listener to the district dropdown
districtDropdown.addEventListener('change', populateCollegesDropdown);
function submitForm() {
var college = document.getElementById("colleges").value;
var logo = document.getElementById("logoInput").files[0];
var session = document.getElementById("session").value;
var yearSem = document.getElementById("yearSem").value;
var subject = document.getElementById("subject").value;
var teacher = document.getElementById("teacher").value;
var branch = document.getElementById("branch").value;
var name = document.getElementById("name").value;
var enrollment = document.getElementById("enrollment").value;
// Check if any field is empty
if (!college || !session || !yearSem || !subject || !teacher || !name || !branch) {
alert("Please fill in all fields!!");
return;
// Stop further execution
}
sessionStorage.setItem("college", college);
sessionStorage.setItem("session", session);
sessionStorage.setItem("yearSem", yearSem);
sessionStorage.setItem("subject", subject);
sessionStorage.setItem("teacher", teacher);
sessionStorage.setItem("name", name);
sessionStorage.setItem("enrollment", enrollment);
sessionStorage.setItem("branch", branch);
if (logo) {
var reader = new FileReader();
reader.onloadend = function() {
sessionStorage.setItem("logo", reader.result);
window.location.href = "format.html";
}
reader.readAsDataURL(logo);
} else {
window.location.href = "format.html";
}
}