Home > Software engineering >  How can I save checkbox state to my database?
How can I save checkbox state to my database?

Time:11-15

I'm trying to create a Todo-list app using (nodejs,ejs...) so for every todo I create for it a checkbox if someone finish his job and bin recycle to delete this job so, I save my data using mongodb but I've problem when check any to do I didn't save this to my database and I don't know how so when I reload the page this checked disappear so: My question is how to save if I do checked my checkbox

<div class = "box">
  
         <% DoList.forEach(function(elem) { %>
         <div class = "item">
             <input type="checkbox">
            <p class = items> <%=elem %></p>
            <form action="/delete" method = "post">
            <button class="delete" type = "submit" name = "delete" value = '<%=elem%>'><img src="stylee/bin.png" alt="bin cycle"></button>
            </form>
         </div> 
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

add your checkbox inside the form and add something like $yourcheckbox= isset($_POST['yourcheckboxname'])?1:0; 1 mean check 0 mean uncheck

  • Related