What is the best way to store javascript generated innerhtml in the database?
The best way to go here probably would be to store the questions in a database table (e.g. questions) with question id and question text, then store all possible answers for question in another table (e.g. answers) in which there would be answer id, parent question id and answer text.
This would ensure some kind of database structure that would allow us to find questions and answers by some kind of numbers.
Then in the view we would loop through all questions and in each question loop through each answer, rendering it. In the HTML forms or JS buttons each question and answer would have a unique ID combination. Upon answering the question by selecting a specific answer, instead of sending the actual text of question or answer, we would send the id of answer.
The user answer could be saved in a table user_answers where it would store some kind of user id together with the id of answer. Afterwards all user answers could be acquired through a SQL query, actual answers could be joined to them and we could see which user answered to which question with which answer. :)
Hope this helps!
The app that I'm creating is a single page questionnaire. The questions displayed are changed by the press of a button that also saves the answers given in a django form in my database. Through using ajax and Javascript I made it possible to do this without refreshing the page. However the answers are not coupled to the questions in the database. What is the best way to save these questions in the database as well?