I have a dropdown that is populated based off a jSON object I have created. I am trying to pass the text value "wineSupplier" to be the text selection in the dropdown, but instead it is passing the array value in the POST to Node.
Thus, if my dropdown has the following options:
A
B
C
D
and I choose "C" the value of 2 is being passed, I would like to be able to receive "C"
Code Snippet from wines.ejs:
<form action="/createWine" method="POST">
<p>Select the Wine Supplier:</p>
<select name="wineSupplier" ng-model="supplierSelection" ng-options="supplier as supplier.supName for supplier in suppliers">
</select>
<label>Wine Name:</label>
<input type="text" name="wineName" placeholder="Wine Name"/>
<label>Wine Producer:</label>
<input type="text" name="wineProducer" placeholder="Wine Producer"/>
<label>Wine Colour:</label>
<input type="text" name="wineColour" placeholder="Wine Colour"/>
<label>Wine Type:</label>
<input type="text" name="wineType" placeholder="Wine Type"/>
<label>Wine Country:</label>
<input type="text" name="wineCountry" placeholder="Wine Country"/>
<p>
<button type="submit" class="btn">Submit</button>
</p>
</form>
Code Snipper from app.js
//Create a new wine objhect
app.post('/createWine', function(request, response) {
//create and save a wine model
var wine = new myWine({
wineSupplier: request.body.wineSupplier,
wineName: request.body.wineName,
wineProducer: request.body.wineProducer,
wineColour: request.body.wineColour,
wineType: request.body.wineType,
wineCountry: request.body.wineCountry
});
//save to model
wine.save(function(err, model) {
if (err) {
response.send(504, 'There was an error');
}
else {
response.redirect('/');
}
});
});
supplierlook like?supplieris getting treated, or what it is.