Book Image

MooTools 1.2 Beginner's Guide

Book Image

MooTools 1.2 Beginner's Guide

Overview of this book

MooTools is a simple-to-use JavaScript library, ideal for people with basic JavaScript skills who want to elevate their web applications to a superior level. If you're a newcomer to MooTools looking to build dynamic, rich, and user-interactive web site applications this beginner's guide with its easy-to-follow step-by-step instructions is all you need to rapidly get to grips with MooTools.
Table of Contents (14 chapters)
MooTools 1.2 Beginner's Guide
Credits
About the Authors
About the Reviewer
Preface

Time for action—building a Date calculator tool


Let's witness the power of the Date plugin by building a pure client-side web tool that adds or subtracts values based on the current date. The tool will allow users to enter how many days, months, or years to add or subtract to the current date. This can be helpful for getting the exact date of past events. Note that this calculator doesn't do input validation, and thus, if you were to use it, you would have to modify it so that it validates the user's input. In particular, if the user inputs an invalid value to add or subtract to the current date, such as 'apple' instead of a number, the script will break.

  1. We'll start by setting up the HTML. The first key element is a paragraph that will show the current date. We will have three form fields to allow users to set the options for the calculation. The first form field is a<select> element (drop-down menu) that will determine what operation we will use: either Add or Subtract. The second...