Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <form name="form1">
  2. <label for="ans0">
  3. <input type="radio" name="answer" id="ans0" value=0>
  4. </label>
  5. <input type="button" id="next" value="Next">
  6. <input type="button" id="back" value="Back">
  7. </form>
  8. ....
  9. function nextClick(){
  10. //jots down answers
  11. answerSheet[currentQuestion] = $("#form1 input[name='answer']:checked").val();
  12. ...
  13. currentQuestion++;
  14. populateQA();
  15. ...
  16. }
  17. function populateQA(){
  18. //code to replace question and answers from an array
  19. }
  20. function backClick(){
  21. currentQuestion--; // Navigates to the last question
  22. var prevAns = answerSheet[currentQuestion];
  23. alert(prevAns); // my test
  24. $("#form1 input[value=" + prevAns + "]").attr("checked", true);
  25. populateQA();
  26. }
  27. var currentQuestion = 0;
  28. var answerSheet = [];
  29. ...
  30. $("#next").on("click", nextClick);
  31. $("#back#).on("click", backClick);
  32.  
  33. $("#form1 input[value=" + prevAns + "]").attr("checked", true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement