I’m trying to create a Todo-list app using (nodejs,ejs…) so for every todo I create a checkbox. If someone finishes his job and uses the button bin recycle to delete it, I save that using MongoDB but I’ve a problem when checking. When I reload the page this checked box disappears. In other words, my question is: How to save the information in my database if the checkbox is checked?
JavaScript
x
12
12
1
<div class="box">
2
3
<% DoList.forEach(function(elem) { %>
4
<div class="item">
5
<input type="checkbox">
6
<p class=i tems>
7
<%=elem %>
8
</p>
9
<form action="/delete" method="post">
10
<button class="delete" type="submit" name="delete" value='<%=elem%>'><img src="stylee/bin.png" alt="bin cycle"></button>
11
</form>
12
</div>
Advertisement
Answer
add your checkbox inside the form and add something like $yourcheckbox= isset($_POST[‘yourcheckboxname’])?1:0; 1 mean check 0 mean uncheck