0

I am able to run the Get method and HTML form also visible on browser using Get method but when I am clicking on submit button nothing is happening, no error nothing. it shows the same HTML form page.

HTML code:
  <!DOCTYPE html>enter code here
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Calculator</title>
  </head>
  <body>
<form action="/" method="post">
  <h1>Calculator</h1>
  <input type="text" name="num1" placeholder="Number 1">
  <input type="text" name="num2" placeholder="Number 2">
  <button action="/" type="button" name="button">Submit</button>
</form>
  </body>
</html>

Node Js code:

//jshint esversion:6

const express=require("express");
const app=express();

app.get("/", function(req,res){
res.sendFile( __dirname+"/index.html");
});

app.post("/", function(req,res){
  res.send("Thanks for post");
});

app.listen(3000, function(){
  console.log("Server Started On Port 3000");
});

1 Answer 1

1

Your button type should be Submit

    <button type="submit" value="Submit">Calculator</button>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.