1.Я пытаюсь получить данные из формы, и когда я ввожу отметки, они отображают ошибку в следующем (/workspace/goorm-ide-test/rps/node_modules/express/lib/router/route.js: 137: 13) stringValue: '"[\ '20 \', \ '\']" ', вид:' Number ', значение: [Array], путь:' historyMarks ', причина: [MongooseError], сообщение:' Ошибка приведения к номеру для значения "[\ '20 \ ', \' \ ']" по пути "historyMarks", имя:' CastError '},
<%- include("./partials/header") %>
<div class="container">
<div class="row">
<h1 style="text-align: center;">
Add Result
</h1>
<div style="width:30%; margin: 25px auto;">
<form action="/result" method="POST">
<table class="table">
<thead>
<tr>
<th scope="col">SNo</th>
<th scope="col">SubjectName</th>
<th scope="col">Subject Code</th>
<th scope="col">MidTerm Marks</th>
<th scope="col">Theory Marks</th>
<th scope="col">Practical Marks</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td><input type="text" name="subject" placeholder="subject name"></td>
<td><input type="text" name="subCode" placeholder="subject code"></td>
<td><input type="number" name="midtermMarks" placeholder="midtermMarks"></td>
<td><input type="number" name="theoryMarks" placeholder="theoryMarks"></td>
<td><input type="number" name="pracMarks" placeholder="pracMarks"></td>
</tr>
<tr>
<th scope="row">2</th>
<td><input type="text" name="subject" placeholder="subject name"></td>
<td><input type="text" name="subCode" placeholder="subject code"></td>
<td><input type="number" name="midtermMarks" placeholder="midtermMarks"></td>
<td><input type="number" name="theoryMarks" placeholder="theoryMarks"></td>
<td><input type="number" name="pracMarks" placeholder="pracMarks"></td>
</tr>
</tbody>
</table>
<div class="form-group">
<button class="btn btn-lg btn-primary btn-block">SUBMIT</button>
</div>
</form>
</div>
</div>
</div>
<%- include("./partials/footer") %>
2.Это мое приложение. js файл
app.get("/result",function(req,res){
Result.find({},function(err,allResult){
if(err){
console.log(err);
}else{
res.render("result",{results:allResult});
}
});
});
app.post("/result",function(req,res){
subject = req.body.subject;
subCode = req.body.subCode;
midtermMarks = req.body.midtermMarks;
theoryMarks = req.body.theoryMarks;
pracMarks = req.body.pracMarks;
creditPoints = req.body.creditPoints;
totalcreditPoints = req.body.totalcreditPoints;
newResult = {subject: subject,subCode:subCode,midtermMarks:midtermMarks,theoryMarks:theoryMarks,pracMarks:pracMarks,creditPoints:creditPoints,totalcreditPoints:totalcreditPoints}
Result.create(newResult,function(err,results){
if(err){
console.log(err);
}else{
res.redirect("/result");
}
});
});
app.get("/result/new",function(req,res){
res.render("new");
});