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 option using Ajax

Often adding the entire select box is more than is needed to handle the job. Still using our previous recipe, let us just replace the option list of the existing SELECT element instead of adding the entire element.

Getting ready

This recipe is an extension of the previous recipe. Prepare for a simple twist that makes it easier to handle.

How to do it...

Create a FORM with a SELECT element. Use Ajax to call in new OPTION elements and inject them inside the SELECT element:

<form action="javascript:" method="get" id="my_form"> <div id="automobile1" style="background-color:#CDCDCD; margin:5px;"> <table> <tr> <td valign="top">Loan, Lease or Own</td> <td valign="top"> <input name=loanlease[]" type="radio" class="rad2" value="loan"/>Loan<br ...

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