Node.Js prompt user input

92 views
Skip to first unread message

Amol

unread,
Sep 5, 2014, 2:47:38 PM9/5/14
to nod...@googlegroups.com

I'm creating a desktop application using Node.JS that talks to SQL Server for MAC users .

Is it possible in Node.JS to take the input from the user and display the data from SQL server based on user input?

For example, in the code below, can I put an input box onload and allow user to input customercodeand display InvoiceNumber and customername.

Also, will I be able to run the below code on MAC?

var http = require('http');
var edge = require('edge');
var port = process.env.PORT || 8080;

var getTopUsers = edge.func('sql', function () {
   /* SELECT TOP 5 * FROM InvoiceHeader ORDER BY InvNumber DESC */
});

function logError(err, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write("Error: " + err);
res.end("");
   }    

http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/html' });

  getTopUsers(null, function (error, result) {
      if (error) { logError(error, res); return; }
      if (result) {
          res.write("<ul>");
          result.forEach(function(user) {
              res.write("<li>" + user.InvNumber + " " + user.CompanyCode + ": " + user.CompanyName + "</li>");
          });
          res.end("</ul>");
      }
      else {
      }
  });
}).listen(port);
console.log("Node server listening on port " + port);

Ryan Schmidt

unread,
Sep 8, 2014, 11:14:14 PM9/8/14
to nod...@googlegroups.com

On Sep 5, 2014, at 1:47 PM, Amol wrote:
>
> I'm creating a desktop application using Node.JS that talks to SQL Server for MAC users .
>
> Is it possible in Node.JS to take the input from the user and display the data from SQL server based on user input?
>
> For example, in the code below, can I put an input box onload and allow user to input customercodeand display InvoiceNumber and customername.

You can write code to do anything you want.


> Also, will I be able to run the below code on MAC?

I don't see why not.


Reply all
Reply to author
Forward
0 new messages