Advertisement
ASdzxf

Untitled

Feb 20th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <!doctype html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
  6. <title>Surveys</title>
  7. </head>
  8. <html lang="en">
  9. <body>
  10. <script>
  11. function onClick() {
  12. var a = document.getElementsByClassName('question')
  13. for (var i = 0; i < a.length; i++) {
  14. b = a[i].getElementsByClassName('answer')
  15. for (var j = 0; j < b.length; j++){
  16. c = b[j].getElementsByTagName('input')
  17. console.log(c)
  18. }
  19. // fetch(
  20. // 'http://localhost:8000/complete_survey/create/',
  21. // {
  22. // method: 'POST',
  23. // headers: new Headers(),
  24. // body: JSON.stringify({survey_id: {{ survey.id }}, user_id: 1, question_id: a[i].id , answer_id: a[i]})
  25. // }
  26. // ).then((res) => console.log(res))
  27. }
  28. }
  29. </script>
  30. {% for question in questions %}
  31. <div class="question" id="{{ question.id }}">
  32. <p>{{ question.content }}</p>
  33. {% for answer in answers %}
  34. {% if answer.question_id == question.id %}
  35. <div class="answer" id="{{ answer.id }}">
  36. <input type="checkbox">
  37. {{ answer.content }}
  38. <p></p>
  39. </div>
  40. {% endif %}
  41. {% endfor %}
  42. </div>
  43. {% endfor %}
  44. <p><button name="foo" value="foo" onclick="onClick()">Submit</button></p>
  45. </body>
  46. </html>
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement