Forms are boring! Or are they? Make any form more interesting by morphing between your form's questions using mootools, a JavaScript framework. Just click the first link below and click "Next Question >>" to see the effect in action. Then click the second link to see what the page would look like if the user had JavaScript disabled.
Demo with JavaScript Enabled
Demo with JavaScript Disabled (Simulated)
Not only can this be used with a form, but with anything that you want
to break up into steps, such as a wizard that guides the user through a
list of new features for a product.
The technique I use is known as unobtrusive JavaScript, which means the page does not rely on the JavaScript to work. Rather, enabling JavaScript will result in some "bells and whistles," but if it's turned off the page is still 100% functional. My goal was to keep this script as simple as possible, so feel free to edit it and use it on any of your projects—free of charge or limitation.
The script basically works like this:
- Get all the questions, or steps, in the form.
- Dynamically add some navigation controls to move forward and backward for each question.
- Hide all the questions or steps, except for the first step.
Whenever a link is clicked an event is called to handle which step is faded in as the current step is faded out.
Download mootools script
Download fade effect script
Note: Everything in the "options" section of the class is there to
allow you to easily customize the script. The "initalize" section is
basically a constructor for the class itself.