I am developing a quick node.js app using express and I am a newbie to NODE. For pages I am just using plain html.
Basically I have a form as follows:
<form id="tableForm" action="getJson">
<select class="selectpicker" data-style="btn-info" name="selectpicker">
<optgroup label="Select Table">
<option name="" value="0">Select table</option>
<option name="table1" value="1">Table 1</option>
<option name="table2" value="2">Table 2</option>
<option name="table3" value="3">Table 3</option>
</optgroup>
</select>
</form>
Basically, I need to get the value selected once done I need it to be passed a app.get() call but my questions is how do I get the value and call the API?
var express = require('express'),
app = express();
app.use(express.bodyParser());
// as only one page can use res.sendfile to render the page which will
// contain the dropdowns ...
app.get('/', function(req, res){
res.sendfile('views/index.html');
});
app.get('/getJson', function (req, res) {
console.log(req.body.);
});
app.listen(process.env.PORT);
So I need to call the getJson() with the value being passed in.
Cheers!