Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Maintain checkbox status in MongoDB

I have a form where users enter data that includes a request for more information. This data is stored in a MongoDB database. Administrators can view each entry in a table on a separate page called list-applicants.html, with a checkbox in the last column of every row that can mark the request as 'complete' for each row/entry. The problem I run into is that checkbox is not being stored in the database.

Data is first stored in a POST routine in my server.js file.

app.post('/api/applicants', async (req, res) => {
    console.log('You posted from a form!');
    console.log(req.body);

    const data = { ...req.body, dateOfApplication: new Date() };

    const collection = client.db("applications").collection("applicants");
    try {
        await collection.insertOne(data);
    } catch (error) {
        console.log(error.message);
    }
    res.status(201);
    res.redirect('/list-applicants.html');
});

In my list-applicants.html file I have the following:

async function getAllApplicants() {
    const response = await fetch('/api/applicants');
    const data = await response.json();

    const { MongoClient, ServerApiVersion } = require('mongodb');
    const dburi = process.env.DATABASE_URI;
    const client = new MongoClient(dburi, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });

    const tableContent = document.getElementById('table-content');

    for (const applicant of data) {
        tableContent.innerHTML += `
            <tr>
                <td>${applicant.fname}</td>
                <td>${applicant.lname}</td>
                <td>${applicant.email}</td>
                <td>${applicant.phone}</td>
                <td>${applicant.campus}</td>
                <td>${applicant.request}</td>
                <td>${applicant.dateOfAttendance}</td>
                <td><input type="checkbox" id="requestComplete" value="complete"></td>
            </tr>
        `
    }
}

I understand I need to somehow do a POST to the MongoDB from the list-applicants.html file. I am just not quite sure how to do that in my list-applicants.js file.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!