-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
88 lines (64 loc) · 2.36 KB
/
Copy pathscripts.js
File metadata and controls
88 lines (64 loc) · 2.36 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
let projects = [
{
title: "Interactive Gallery",
description: "A dynamic image gallery built using JavaScript.",
link: "#"
},
{
title: "Portfolio Website",
description: "A personal portfolio website built using HTML, CSS, and JavaScript.",
link: "#"
},
{
title: "Task Management App",
description: "An app to manage tasks dynamically.",
link: "#"
},
{
title: "Weather App",
description: "A weather app using API to fetch real-time data.",
link: "#"
}
];
function displayProjects() {
const projectContainer = document.querySelector('.projects-container');
for (let i = 0; i < projects.length; i++) {
let project = projects[i];
let projectCard = document.createElement('div');
projectCard.className = 'project-card';
// Create the project structure with title, description, and link
projectCard.innerHTML = `
<h2>${project.title}</h2>
<p>${project.description}</p>
<a href="${project.link}" class="btn">View More</a>
`;
// Add the project card to the project container
projectContainer.appendChild(projectCard);
}
}
document.addEventListener('DOMContentLoaded', function () {
displayProjects(); // Call function to display projects when DOM is ready
// Handle button clicks on "View More"
document.querySelector('.projects-container').addEventListener('click', function (event) {
if (event.target.classList.contains('btn')) {
event.preventDefault();
alert('This is a placeholder for project details!');
}
});
});
function submitForm(event) {
event.preventDefault(); // Prevent page reload
let name = document.getElementById('name').value;
let email = document.getElementById('email').value;
let message = document.getElementById('message').value;
if (name === "" || email === "" || message === "") {
alert("Please fill in all fields!");
} else {
console.log("Form Submitted:", { name, email, message });
alert("Thank you for reaching out, " + name + "! We will get back to you soon.");
}
}
let contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', submitForm); // Callback function for form submission
}