Job Board

Project Structure

Copy codejob-board/
├── index.html
├── style.css
└── script.js

1. index.html

htmlCopy code<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Job Board</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <h1>Job Board</h1>
        <form id="job-form">
            <input type="text" id="job-title" placeholder="Job Title" required>
            <input type="text" id="job-company" placeholder="Company Name" required>
            <input type="text" id="job-location" placeholder="Location" required>
            <textarea id="job-description" placeholder="Job Description" required></textarea>
            <button type="submit">Post Job</button>
        </form>
    </header>
    <main>
        <h2>Job Listings</h2>
        <div id="job-listings"></div>
    </main>
    <script src="script.js"></script>
</body>
</html>

2. style.css

cssCopy codebody {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f4f4;
}

header {
    background: #007bff;
    color: white;
    padding: 10px 20px;
}

h1, h2 {
    margin: 0;
}

form {
    display: flex;
    flex-direction: column;
}

input, textarea {
    margin: 5px 0;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

button {
    padding: 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

button:hover {
    background: #218838;
}

#job-listings {
    margin-top: 20px;
}

.job-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
    margin: 10px 0;
}

3. script.js

javascriptCopy codedocument.getElementById('job-form').addEventListener('submit', function(event) {
    event.preventDefault();

    const title = document.getElementById('job-title').value;
    const company = document.getElementById('job-company').value;
    const location = document.getElementById('job-location').value;
    const description = document.getElementById('job-description').value;

    const job = {
        title,
        company,
        location,
        description
    };

    addJobToListings(job);

    // Clear the form
    this.reset();
});

function addJobToListings(job) {
    const jobListings = document.getElementById('job-listings');
    
    const jobItem = document.createElement('div');
    jobItem.classList.add('job-item');
    jobItem.innerHTML = `
        <h3>${job.title}</h3>
        <p><strong>Company:</strong> ${job.company}</p>
        <p><strong>Location:</strong> ${job.location}</p>
        <p>${job.description}</p>
    `;

    jobListings.appendChild(jobItem);
}

How It Works

  1. HTML Structure: The index.html file sets up a form for submitting job postings and a section to display job listings.
  2. Styling: The style.css file provides basic styling for the application.
  3. JavaScript Functionality: The script.js file handles the form submission, creates job listings, and appends them to the job listings section.

Running the Application

  1. Create a folder named job-board and add the three files as shown in the structure.
  2. Open index.html in your web browser.
  3. You can now post jobs, and they’ll appear in the job listings section.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *