O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a select box to the HTML DOM

Adding a SELECT box to the DOM can be tricky, but MooTools gives us the ability to make it look easy. This example will help us solve the common problem of a secondary SELECT menu upon modification of a first.

Getting ready

In our example, we ready ourselves by knowing the subordinate data to the first SELECT element's options. In a real-world usage, it is likely we would Ajax in the secondary data. If the planned use of the recipe includes Ajaxing in the secondary data, be sure to prepare the server-side script that returns the HTML before beginning.

How to do it...

Use a primary SELECT drop-down menu to dynamically create a secondary SELECT drop down:

<form action="javascript:" method="get" id="my_form"> <div ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required