...

View Full Version : Form that only shows 3 questions at a time



a4udi
12-18-2008, 04:35 PM
I'm not sure if this is something that would be done with PHP or easier with CSS... I really have no clue. What I want to do is have a quiz with roughly 12 questions, but break it up into sections of 3. So a user would see three questions, select multiple choice (radio buttons) and then they could click "next" and the page would refresh to the next 3 questions and store the questions already answered... then at the end it would give the answers. What am I looking at to program something like this? :confused:

masterofollies
12-18-2008, 04:55 PM
Yes PHP can do this. You could save the answers in a SESSION.

whizard
12-18-2008, 07:17 PM
Basically, you need to have a session variable which records which set of questions you are on, as well as a session variable to hold the answer to each problem. each time the user advances to the next page, you check to see which set of problems you are on, and show the correct ones.

a4udi
12-22-2008, 10:39 PM
I was hoping not to have to do "actual" multiple pages or sessions... what I was thinking of, was is it possible to have maybe 3-4 sets of questions within <div>'s and then show only 1 div at a time, then hide it after a users clicks a "next" link?

So like <div> first 4 questions </div> NEXT ---> then it shows <div> second set of questions </div>.. then at the end a "submit" button to calculate everything?

ShaneC
12-23-2008, 12:28 AM
I was hoping not to have to do "actual" multiple pages or sessions... what I was thinking of, was is it possible to have maybe 3-4 sets of questions within <div>'s and then show only 1 div at a time, then hide it after a users clicks a "next" link?

So like <div> first 4 questions </div> NEXT ---> then it shows <div> second set of questions </div>.. then at the end a "submit" button to calculate everything?

That could really only be accomplished with PHP and Javascript - AKA AJAX. What you would do is make it so the Javascript would hide or unhide (style.display = "none";) depending on the answers or if certain fields were answered. You would then use AJAX to adjust either the $_SESSION variable or $_COOKIE using PHP.

For more details on AJAX, check the Wikipedia page (http://en.wikipedia.org/wiki/AJAX).

lokeshshettyk
12-23-2008, 11:35 AM
PHP, Ajax and Jquery make it classic :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum