Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2022 06:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
EJS index file with dynamic data
<!-- 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>
<th>Drug Name</th>
<th>Tablets per Card</th>
<th>Tablets per Pack</th>
<th>Taken per Day</th>
<!-- Loop through drugs -->
<% for(let i = 0; i < drugs.length; i++) {%>
<td><%= i + 1 %></td>
<td><%= drugs[i].name %></td>
<td><%= drugs[i].card %></td>
<td><%= drugs[i].pack %></td>
<td><%= drugs[i].perDay %></td>
<a href="/update-drug?id=<%= drugs[i]._id%>">
<span class='fa fa-edit'></span>
<a class="delete" data-id=<%= drugs[i]._id%> ><!-- give each delete button a unique ID -->
<span class='fa fa-trash'></span>
<% } %> <!-- End loop -->
<!-- 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