title: How to pass the value of a button ID into a GET request?
body: <p>I have a Node.js application which used a database that consists of many students and their current marks. I am able to view this in a table by first getting the data from MongoDB and sending it to the .ejs file.</p>
  <p><strong>index.js</strong></p>
  <pre><code>router.get(&quot;/dashboard&quot;, function (req, res) {
    markModel.find({}, function (err, allDetails) {
      if (err) {
        console.log(err);
      } else {
        res.render(&quot;marks&quot;, { details: allDetails});
      }
    });
  });
  </code></pre>
  <p><strong>marks.ejs</strong></p>
  <pre><code>&lt;% if(details!=null) { %&gt;
  &lt;table&gt;
  &lt;tr&gt;
      &lt;th&gt;Student&lt;/th&gt;
      &lt;th&gt;Mark&lt;/th&gt;
  &lt;/tr&gt;
  &lt;% details.forEach(function(item){ %&gt;
  &lt;tr&gt;
      &lt;td&gt;&lt;%= item.name%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= item.mark%&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;% }) %&gt;
  &lt;/table&gt;
  </code></pre>
  <p>What I want to do is create an <strong>Update</strong> button in every row that will take me to a separate page where I can update a student's mark. I thought of adding a button where I can use the <code>_id</code> to identify the record but I'm not sure how to pass this value into a <code>GET</code> request to the page where I can update the marks separately.</p>
  <pre><code>&lt;td&gt;&lt;a href=&quot;/update&quot; class=&quot;btn btn-secondary&quot; id = &lt;%= item._id%&gt; &gt;Update&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  <p>Another approach I had was using a form.</p>
  <pre><code>&lt;form method=&quot;post&quot; action=&quot;/marks&quot;&gt;
       &lt;input type=&quot;submit&quot; id=&quot;&lt;%= item._id%&gt;&quot; name=&quot;&lt;%= item._id%&gt;&quot; value=&quot;Update&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>But I got stuck on how to how to pass the value of <code>_id</code> while redirecting to <code>/update</code>.</p>
  <pre><code>router.post(&quot;/dashboard&quot;, function (req, res) {
     res.redirect(&quot;/update&quot;)
  });
  </code></pre>
  <p>This is what I have so far. I'm not sure what to give for the reqID so I have left it blank.</p>
  <pre><code>router.get(&quot;/update&quot;, (req, res) =&gt;
    res.render(&quot;update&quot;, {
      reqID: 
    })
  );
  </code></pre>
  <p>Please let me know if there's anything else I can add and how to resolve this issue.</p>