title: Obtaining Unchecked Checkbox values
body: <p>So I have this code</p>
  
  <pre><code>//Admin Panel Page
  router.get('/admin', ensureAuthenticated, async (req, res) =&gt; {
      if (req.user.admin !== true){
          req.flash('error_msg', 'You do not have access to reports, sorry.');
          res.render('dashboard', {
              name: req.user.name
          })
      }
      else{
          try {
              var adminArray = [];
              var html = "&lt;link rel='stylesheet' href='/css/freelancer.css' type='text/css'/&gt;" +
                          "&lt;script src='https://code.jquery.com/jquery-3.4.1.slim.min.js' integrity='sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n' crossorigin='anonymous'&gt;&lt;/script&gt;" +
                          "&lt;nav class='navbar navbar-expand-lg bg-secondary text-uppercase fixed-top' id='mainNav'&gt;&lt;div class='container'&gt;" +
                          "&lt;a class='navbar-brand js-scroll-trigger' href='/dashboard'&gt;Chinook Winds Logistics LLC&lt;/a&gt;" +
                          "&lt;button class='navbar-toggler navbar-toggler-right text-uppercase font-weight-bold bg-primary text-white rounded' type='button' data-toggle='collapse' data-target='#navbarResponsive' aria-controls='navbarResponsive' aria-expanded='false' aria-label='Toggle navigation'&gt;Menu&lt;i class='fas fa-bars'&gt;&lt;/i&gt;&lt;/button&gt;" +
                          "&lt;div class='collapse navbar-collapse' id='navbarResponsive'&gt;&lt;ul class='navbar-nav ml-auto'&gt;&lt;li class='nav-item mx-0 mx-lg-1'&gt;&lt;a href='/admin' class='btn btn-primary'&gt;Admin Panel&lt;/a&gt;&lt;/li&gt;&lt;li class='nav-item mx-0 mx-lg-1'&gt;" +
                          "&lt;a href='/reports' class='btn btn-primary'&gt;Reports&lt;/a&gt;&lt;/li&gt;&lt;li class='nav-item mx-0 mx-lg-1'&gt;&lt;a href='/users/logout' class='btn btn-primary'&gt;Logout&lt;/a&gt;" +
                          "&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/nav&gt;&lt; br/&gt;&lt;body&gt;&lt;script src='https://kit.fontawesome.com/4a2ea255d5.js' crossorigin='anonymous'&gt;&lt;/script&gt;&lt;div class='container-blog'&gt;&lt;table class='table-primary table-bordered table' style='border-spacing: 10px;'&gt;"+
                          "&lt;tr&gt;&lt;th&gt;Users Name&lt;/th&gt;&lt;th&gt;Email Address&lt;/th&gt;&lt;th&gt;Truck Driver&lt;/th&gt;&lt;th&gt;Truck Number&lt;/th&gt;&lt;th&gt;Admin&lt;/th&gt;&lt;th&gt;Customer&lt;/th&gt;&lt;th&gt;Load Planner&lt;/th&gt;&lt;th&gt;Deactivate Account?&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;form action='/admin' method='post'&gt;";
              await User.find({isVerified: true}, function(err,resp){
                  if(err){
                      console.log('Error Fetching Model');
                      console.log(err);
                  }
                  adminArray = resp;
                  adminArray.forEach(function(data){
                      html += "&lt;td&gt;" + data.name + "&lt;/td&gt;";
                      html += "&lt;td&gt;" + data.email + "&lt;/td&gt;";
                      html += "&lt;td&gt;&lt;input type='hidden' name=truckDriver value=''&gt;&lt;input class='form-control' name='truckDriver' type='checkbox' value=" + data.email + "&gt;&lt;/input&gt;&lt;/td&gt;";
                      html += "&lt;td&gt;&lt;input class='form-control' name='truckNumber' type='number'&gt;&lt;/input&gt;&lt;/td&gt;";
                      html += "&lt;td&gt;&lt;input type='hidden' name=admin value=''&gt;&lt;input class='form-control' name='admin' type='checkbox' value=" + data.email + "&gt;&lt;/input&gt;&lt;/td&gt;";
                      html += "&lt;td&gt;&lt;input type='hidden' name=customer value=''&gt;&lt;input class='form-control' name='customer' type='checkbox' value=" + data.email + "&gt;&lt;/input&gt;&lt;/td&gt;";
                      html += "&lt;td&gt;&lt;input type='hidden' name=loadPlanning value=''&gt;&lt;input class='form-control' name='loadPlanning' type='checkbox' value=" + data.email + "&gt;&lt;/input&gt;&lt;/td&gt;";
                      //html += "&lt;td&gt;&lt;input class='form-control' name='deactivate' type='checkbox' value=" + data.email + "&gt;&lt;/input&gt;&lt;/td&gt;";
                      html += "&lt;/tr&gt;&lt;tr&gt;";
                  });
                  html += "&lt;/tr&gt;&lt;/table&gt;&lt;input class='btn btn-primary' type='submit'&gt;&lt;/input&gt;&lt;/form&gt;&lt;/div&gt;&lt;/body&gt;";
                  html += "&lt;script src='js/freelancer.js'&gt;&lt;/script&gt;";
                  html += '&lt;script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"&gt;&lt;/script&gt;&lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"&gt;&lt;/script&gt;&lt;script src="public/js/freelancer.js"&gt;&lt;/script&gt;&lt;script src="public/js/jqBootstrapValidation.js"&gt;&lt;/script&gt;&lt;script src="public/js/contact_me.js"&gt;&lt;/script&gt;';
                  res.send(html);
              })
          }
          catch (e){
              res.send('error_msg');
              console.log(e);
          }
      }
  });
  </code></pre>
  
  <p>This creates a table of all verified users. This...</p>
  
  <pre><code>// Admin Update Panel
  router.post('/admin', ensureAuthenticated, async (req, res) =&gt; {
      try {
          const { truckDriver, truckNumber, admin, customer, loadPlanning } = req.body;
          await User.find({isVerified: true}, function(err,data){
              adminArray = data;
              console.log(req.body);
              q = 1;
              adminArray.forEach(async (data, res) =&gt;{
                  if(truckDriver[q] == data.email){
                      await User.findOneAndUpdate({email: data.email}, {truckDriver: true}, {useFindAndModify: false});
                  }
                  if(admin[q] == data.email){
                      await User.findOneAndUpdate({email: data.email}, {admin: true}, {useFindAndModify: false});
                  }
                  if(customer[q] == data.email){
                      await User.findOneAndUpdate({email: data.email}, {customer: true}, {useFindAndModify: false});
                  }
                  if(loadPlanning[q] == data.email){
                      console.log(yes);
                      await User.findOneAndUpdate({email: data.email}, {loadPlanning: true}, {useFindAndModify: false});
                  }
                  q = q + 2;
                  console.log(q);
              });
          });
          req.flash('success_msg', 'Your accounts have been processed!');
          res.redirect('/admin');
      }
      catch (e){
          res.send('error_msg');
          console.log(e);
      };
  });
  </code></pre>
  
  <p>Is supposed to iterate through the submitted form and update user accounts based on the previous form's data.</p>
  
  <p>I am trying to make it so that if a checkbox is unchecked, the form will still pass a value in its place (can be null). I tried using Hidden fields to accomplish this, but when I hit submit, the form will post all the hidden checkboxes and all the checked checkboxes.</p>
  
  <p>How can I make it so that either all unchecked checkboxes pass a null variable to POST, or continue to do it the way I am and remove the values of hidden checkboxes if the corresponding checkbox is checked?</p>