I'm trying to get a value from input checkbox when checkbox is checked, then send some text like 'on' into a table field and when checkbox is unchecked, delete the value from table field. Is it there the way to do it?
This is my controller
hide: function(req, res){
var id = req.param('id');
var open = req.param('open');
Category.update({id:id},{open:open}).exec(function(err){
if(err){
return res.send('err');
}
res.redirect('/diy');
});
}
this is the html
<% for(var i=0; i<categories.length; i++ ){ %>
<tr>
<td> <%= categories[i].id %> </td>
<td> <%= categories[i].name %> </td>
<td><a href="/category/edit?id=<%= categories[i].id %>" class="d-inline btn btn-primary">Edit</a></td>
<td><a class="d-line btn btn-danger" href="category/delete?id=<%= categories[i].id %>">Delete</a></td>
<form method="POST" action="/category/show">
<td><input type="checkbox" name="open" id="check" />Show Catagory</td>
</tr>
<% } %>
</tbody>
</table>
<input class="btn btn-primary" type="submit" value="submit"/>
</form>
Aucun commentaire:
Enregistrer un commentaire