I’m just trying to get the values from html text field and assigning the values into variables.
I need html to get all these values and post back the response somewhere in the .html file.
html:
<body>
<form>
<label for="stageURL">Stage URL:</label><br>
<input type="text" id="stageURL" name="stageURL"><br>
<label for="prodURL">Production URL:</label><br>
<input type="text" id="prodURL" name="prodURL">
</form>
<button type="submit" form="form1" value="Submit">Submit</button>
</body>
Express.js
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
const port = 3000;
router.get('/',function(req,res){
res.sendFile(path.join(__dirname+'/index.html')); // The user will see the html file in this path.
let stageUrl = req.query.stageURL; //Need to fetch the input field data.
let prodUrl = req.query.prodURL; // Need to fetch input field data.
res.send(stageUrl+" : "+prodUrl); //print it back somewhere in the html file.
});
html view:
I want to show the above html page when user tried to hit http://localhost:3000
and I just need to get the stage and prod url when the user click submit button.