Master - detail AJAX select boxes
Home - Tutorials - AJAX basic tutorials
In this tutorial I will present you how to create a master - detail select box in your forms. Select one item from the master field and the details will be filled accordingly to your selection.
Tutorial info:
Name: | Master - detail AJAX select boxes |
Total steps: | 4 |
Category: | AJAX basic tutorials |
Date: | 2007-11-16 |
Level: | Normal |
Product: | See complete product |
Viewed: | 84167 |
Bookmark Master - detail AJAX select boxes
Step 1 - The master - detail concept
Master - detail AJAX select boxes
Time to time you need to create web forms where your visitors can select first a main category and then a subcategory. Think a bit, it is not so easy to implement this solution. Why? You need to fill the first (master) list and the second (detail) list as well. However at design time you don't know which value is selected in the master list so how you should fill the detail page?
Let's see an example:
Main category items:
- Audi
- BMW
- Mercedes
- Lexus
And the subcategories are:
- A3, A4, A6, A8 for Audi
- 320, 520, 630, 745 for BMW
- A180, C200, E320, S500 for Mercedes
- IS200, GS300, LS600 for Lexus
So to fill the master list is quite simple, just add the 4 car brand to the list as here:
Code:
In case of the detail list we have the problem what items to add. If Audi is the first then the detail select box should look like this:
Code:
But if the visitor made any changes in the master list then our detail list items still the same.
And here comes AJAX to help us. We will send a message to the server when the visitor have changed the value of the master select box. The server will construct a list of relevant detail items and sends back to the browser. Afterwards the browser assigns this list to the detail list.
Now let's see how to implement it.
Next Step of Master - detail AJAX select boxes
Tags: ajax select box, ajax master detail, master detail select box
Master - detail AJAX select boxes - Table of contents |
---|
Step 1 - The master - detail concept |
Step 2 - AJAX to get details |
Step 3 - AJAX server side script |
Step 4 - AJAX master - detail select client side code |