Sending client side form input to server side database query via Node.js and return results to client

I am developing a web application where the user can type in a "device id" on the web page (we have 100's of devices out on the field in production use each with a unique ID), that result entered by the user will be sent to the Node.js server that in return will store it into a variable and use it in a SQL Query to retrieve results about that particular device from the database server and then display the results back to the client web page.

Currently the form input feature has not been implemented yet even though I've already coded the form code in html.

The program works fine as it is if I were to manually change the DEVICE_ID to the device I wish to retrieve data from in the code but of course I want to be able to enter this on the client page instead of me having to change it in the server-side source code manually.

"use strict";
var pg = require('pg').native;
var http = require('http');
var $ = require('cheerio');
var fs = require('fs');
var url = require('url');

var htmlString = fs.readFileSync('index.html').toString();
var parsedHTML = $.load(htmlString);

var dbUrl = "tcp://URL HERE/";

// The Sign-ID
var DEVICE_ID = '2001202';

// Create the http server
http.createServer(function (request, response) {
    var request = url.parse(request.url, true);
    var action = request.pathname;

    // Connect and query the database
    pg.connect(dbUrl, function(err, client) {
        // The complete sql query for everything that's needed for the app!
        client.query("SQL QUERY IS HERE" + DEVICE_ID + "etc..", 
            function (err, result) {
                // Remaining program code is here that performs DOM based 
                // manipulation to display results returned from the server
                // to the client side page.

                // Time to Render the document and output to the console
                console.log(parsedHTML.html());

                // Render the document and project onto browser
                response.end(parsedHTML.html());
            }
        ); // End client.query
    }); // End pg.connect
}).listen(8080); // End http.CreateServer

pg.end();

I've considered the following: 1) Use An OnClick() function from within the HTML code, like this:

onclick="lookupSignID()

Then include an external JS file from within the HTML that includes the lookupSignID() function however I soon found out this is only performing client-side function and is not what I want.

2) AJAX is only good for if the server is generating new information by itself, therefore I can't use AJAX since the user is entering the device ID to get information from it.

3) Possibly using POST/ GET

Can anyone please advise on what course of action I should take? If solution (3) is the best way how would I go about doing this? Can it be integrated into my existed code (shown above) without many changes?

Thanks!

If you used jQuery on the client side with an AJAX POST function, and then on the server side, you have express.js, you could do this:

app.post('/deviceid', function(req, res) {
   var deviceid = req.param('deviceid')
   console.log(deviceid)
   ...
})