mercredi 23 novembre 2016

How to present checkbox values in HTML (using ejs) after extracting data from mongo for User to Edit?

I currently save data into mongo for a multiple choice question and mark the correct answers, In mongo I save them something like question.options.option1.check = "on" for the correct answers.

When I go to the "edit" page I pull the particular record from mongo which is available in ejs as "question" and I am easily able to fill the editable fields values as question.question, or question.options.option1.text etc. But I also want to mark the check boxes that have been previously checked. Below is an example of the checkbox. when I use > it does not work, I also tried "> this does not work either. But if I give the attribute "checked" = "any value here or no value at all" it checks, which is wrong.

So the question is what is the correct way to check the appropriate checkboxes on the edit page.?




Aucun commentaire:

Enregistrer un commentaire