title: Search query dynamically using postgres, nodejs and html
body: <p>I have created a node.js app and connected to the Postgres database successfully. I also created a .html file with a form that contains an input text field and a submit button.</p>
  
  <p>When I enter something into the text field and press submit button, I want my node.js app to search that record using the entered input text field of the form and display it on the browser.</p>
  
  <p>I've tried using request parameters and fetched the records successfully, but this does not require the use of HTML. I  want it to fetch dynamically with the help of a button.</p>
  
  <p>I've also tried calling the dynamic URI(like "/abc/:xyz") using onclick() on the submit button but didn't get any result.</p>
  
  <h2>node.js[end point that handles the "get" request]</h2>
  
  <pre><code>app.get('/details/:regn_no', (req, res, next) =&gt; {
  
        const regn_no = req.params.regn_no;
  
        const results = [];
  
        pg.connect(connectionString, (err, client, done) =&gt; {
  
          if(err) {
            done();
            console.log(err);
            return res.status(500).json({success: false, data: err});
          }
  
          const query = client.query('select * from vt_owner where regn_no= 
               $1',[regn_no]);
  
          query.on('row', (row) =&gt; {
            results.push(row);
          });
          query.on('end', () =&gt; {
            done();
            return res.json(results);
  
          });
        });
      });
  </code></pre>
  
  <h2>index.html [contains a simple html form]</h2>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1, 
       shrink-to-fit=no"&gt;
      &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"&gt;
  
    &lt;title&gt;GET OWNER DETAILS&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-lg-2"&gt;&lt;/div&gt;
              &lt;div class="col-lg-8"&gt;
  &lt;form id="form"&gt;
  &lt;div class="form-group" id="formID" &gt;
  &lt;label for="regn_no"&gt;REGN_NO&lt;/label&gt;
  &lt;input type="text" class="form-control" id="UserInput" placeholder="Enter 
  regn_no here" name="regn_no"&gt;&lt;br&gt;
  &lt;input type="button" 
  onclick="location.href='http://localhost:3000/details" id="submitButton"  
  value="Submit" /&gt;
  &lt;/div&gt;
  &lt;/form&gt;      
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  ```jquery
  $(document).ready(function(){
       $("#form").submit(function (event) {
            $.post('/details', $("#form").serialize(), function (data) {
              console.log(data) //data is the response from the backend
            });
            event.preventDefault();
          });
   })
  </code></pre>
  
  <p>When i type "regn_no" and click submit. The app should fetch the records matching that specific "regn_no" and display them.</p>