This commit is contained in:
2019-02-28 21:03:21 +01:00
parent 77d846ffde
commit 567932e91e
2 changed files with 2 additions and 1 deletions

View File

@@ -54,7 +54,7 @@ app.post('/search', (req, res) => {
temp = client.db().collection("questions").find(query).toArray(function(err, data) {
arr = splice(data)
page = 0 + parseInt(req.body.page, 10)
res.render('index', {data: arr[page],page:page,maxpages:arr.length()})
res.render('index', {data: arr[page],page:page,pagenums:Array.from(new Array(arr.length()), (x,i) => i),maxpages:arr.length()})
client.close()
})
});

View File

@@ -32,6 +32,7 @@
</ul>
<form class="form-inline my-2 my-lg-0" action="/search" method="post">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="title">
<input type="hidden" name="page" value="0">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>