Results 1 to 3 of 3

Thread: Randomizing questions and answers quiz in jQuery multipage

  1. #1
    Join Date
    May 2017

    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.

    HTML Code:
    <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 class="answers-right">
    		<div class="answer3" tabIndex="3">Cloudy</div>
    		<div class="answer4" tabIndex="4">Windy</div>
    		<div class="clear"></div>
    <div class="next-button">
    	<a class="ui-btn" href="#question2">Next</a>
    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.

  2. #2
    Join Date
    Dec 2012
    I answered this question here:
    Did you forget about this thread?

  3. #3
    Join Date
    Mar 2007
    Also posting in the JavaScript forum and not the JavaScript Frameworks forum...
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center