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 ...
Get MooTools 1.3 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.