Skip to content Skip to sidebar Skip to footer

Passing Variable From Ejs To Js Script

I am trying to pass a variable from ejs to JavaScript function but keep getting undefined in output. Here is the code. It is supposed to render a table with file names and clicking

Solution 1:

I have come up with something like this. It does it job

<script>
    var table = document.getElementById('table'),
        rIndex;
    for (var i = 0; i < table.rows.length; i++) {
        table.rows[i].onclick = function () {
            rIndex = this.rowIndex;
            window.location.href = "/thesis_view/" + this.cells[1].innerHTML;
        }
    }
</script>

Post a Comment for "Passing Variable From Ejs To Js Script"