I am new to Node.js and Express
I am trying to fetch the selected option from the select list of an HTML page and display as a response using node.js
HTML
<form name="survey" id="survey" method="post" action="/survey">
<select name="monthofbirth">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</form>
Index.JS
var express = require('express')
var bodyParser = require("body-parser");
var app = express()
app.use(express.static('public'))
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/survey', function (req, res) {
let month = req.body.monthofbirth;
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
When I try to print the response using the code res.write(<b>${month}</b>); It displays the value of the option like 1, 2, 3 etc but I have to display the text like January, February etc.
please help me out with this :(
Edit:
I am not supposed to change the HTML document so I won't be able to change the option values from 1, 2, 3 to January, February etc;