Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form name="form1">
- <label for="ans0">
- <input type="radio" name="answer" id="ans0" value=0>
- </label>
- <input type="button" id="next" value="Next">
- <input type="button" id="back" value="Back">
- </form>
- ....
- function nextClick(){
- //jots down answers
- answerSheet[currentQuestion] = $("#form1 input[name='answer']:checked").val();
- ...
- currentQuestion++;
- populateQA();
- ...
- }
- function populateQA(){
- //code to replace question and answers from an array
- }
- function backClick(){
- currentQuestion--; // Navigates to the last question
- var prevAns = answerSheet[currentQuestion];
- alert(prevAns); // my test
- $("#form1 input[value=" + prevAns + "]").attr("checked", true);
- populateQA();
- }
- var currentQuestion = 0;
- var answerSheet = [];
- ...
- $("#next").on("click", nextClick);
- $("#back#).on("click", backClick);
- $("#form1 input[value=" + prevAns + "]").attr("checked", true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement