/    Sign up×
Community /Pin to ProfileBookmark

Randomizing questions and answers quiz in jQuery multipage

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>[/code]

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.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rootMay 10.2017 — Also posting in the JavaScript forum and not the JavaScript Frameworks forum... ?
×

Success!

Help @triple3stacks spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...