-
-
Save pbanigo/469c90be581b2fdb641e4a85f6154d94 to your computer and use it in GitHub Desktop.
EJS index file with dynamic data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- add header --> | |
<%- include('includes/_header') %> | |
<!-- end header --> | |
<!-- Main section --> | |
<main id="main"> | |
<a href="/add-drug"> | |
<button id="new">New Drug <i class="fas fa-pills"></i></button> | |
</a> | |
<h2>Drugs</h2> | |
<table> | |
<thead> | |
<tr> | |
<th>ID</th> | |
<th>Drug Name</th> | |
<th>Tablets per Card</th> | |
<th>Tablets per Pack</th> | |
<th>Taken per Day</th> | |
<th>Action</th> | |
</tr> | |
</thead> | |
<tbody> | |
<!-- Loop through drugs --> | |
<% for(let i = 0; i < drugs.length; i++) {%> | |
<tr> | |
<td><%= i + 1 %></td> | |
<td><%= drugs[i].name %></td> | |
<td><%= drugs[i].card %></td> | |
<td><%= drugs[i].pack %></td> | |
<td><%= drugs[i].perDay %></td> | |
<td> | |
<a href="/update-drug?id=<%= drugs[i]._id%>"> | |
<span class='fa fa-edit'></span> | |
</a> | |
<a class="delete" data-id=<%= drugs[i]._id%> ><!-- give each delete button a unique ID --> | |
<span class='fa fa-trash'></span> | |
</a> | |
</td> | |
</tr> | |
<% } %> <!-- End loop --> | |
</tbody> | |
</table> | |
</main> | |
<!-- End main section --> | |
<!-- add footer --> | |
<%- include('includes/_footer') %> | |
<!-- end footer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment