Creating a jQuery mobile site and one section is a questions and answers section. A question and a number of answers are presented to the user and they can select an answer, and press next. When the user presses next, they will be brought to the next page with a different question. I have 40 questions but only want the user to answer 6 (there are no correct answers to the question, they just choose one). How do I randomize this in Javascript so that the same questions aren’t always asked? Beginner in javascript so not 100% sure. I want the questions to be in the h2 tag and the answers to be within the the divs, as seen below.
[code=html]<h2>What is the weather like today?</h2>
<div class=”answers”>
<div class=”answers-left”>
<div class=”answer1″ tabIndex=”1″>Sunny</div>
<div class=”answer2″ tabIndex=”2″>Raining</div>
</div>
<div class=”answers-right”>
<div class=”answer3″ tabIndex=”3″>Cloudy</div>
<div class=”answer4″ tabIndex=”4″>Windy</div>
</div>
<div class=”clear”></div>
</div>
<div class=”next-button”>
<a class=”ui-btn” href=”#question2″>Next</a>
</div>
Lets just say I create a multipage with 40 different pages, one for each question and create a function that randomizes the pages onclick, but the user will only be shown 6 pages then brought onto the section of the site? Would that work? Or is there a completely different, easier way to do this than I am proposing?
Any help will be greatly appreciated.