1

I need a pointer or sample tutorial or some examples to form handling in Node.js. I have a form.html which has 3 buttons "Forward", "Backward", "Stop" and they will have to call a process get and appropriately send messages to the backend component to take appropriate action. My sample node.js that comes when I create the application is good, but it does not have form processing, so a link to some worked examples would help a lot.

Ram Vennam
  • 3,536
  • 1
  • 12
  • 19
Shashi Kiran
  • 63
  • 1
  • 7

1 Answers1

1

You can use the express framework to process the form.

<form action="/processForm" method="POST">
  What's your name?: <input type="text" name="yourname"><br>
  <input type="submit" value="Forward">
</form>

node backend:

app.post('/processForm',function(req,res){
  var yourname=req.body.yourname;
  res.end("Hello " + yourname);
});

Great tutorials: https://codeforgeek.com/2014/09/handle-get-post-request-express-4/ http://www.hacksparrow.com/form-handling-processing-in-express-js.html

Ram Vennam
  • 3,536
  • 1
  • 12
  • 19