Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67556

Pagination url issues with express js

$
0
0

I've created a Pagination and i'm facing some issues, the goal is to when the URL is '/platform' then use the DOM to update the pagination. I'm using Express to pass in the URL path (req.url).

var mainPath = '<%=url[1]%>'
var pathURL = '<%=url[2]%>'
let link1 = document.getElementById('link1')
let link2 = document.getElementById('link2')
let link3 = document.getElementById('link3')
if(mainPath == 'page') {
    let pastPage = pathURL - 1;
    let nextPage = pathURL + 1;
    linkk1.innerHTML = '<a class="page-link" href="/page/'+ pastPage +'">'+ pastPage +'</a>'
    linkk2.innerHTML = '<a class="page-link" href="/page/'+ pathURL +'">'+ pathURL +'</a>'
    linkk3.innerHTML = '<a class="page-link" href="/page/'+ nextPage +'">'+ nextPage +'</a>'
} else if(mainPath == 'platform') {
    let pastPage = pathURL - 1;
    let nextPage = pastPage + 2;
    link1.innerHTML = '<a class="page-link" href="/platform/'+pathURL+'/'+pastPage+'">'+pastPage+'</a>'
    linkk2.innerHTML = '<li id="page-2" class="page-item"><a class="page-link" href="/platform/'+pathURL+'/'+pathNumber+'">'+pathURL+'</a>'
    linkk3.innerHTML = '<a class="page-link" href="/platform/'+pathURL+'/'+pathNum+'">'+nextPage+'</a>'
}

The issue is, when the URL is 'platform', it doesn't update the href to like below

href='/platform'

Viewing all articles
Browse latest Browse all 67556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>