Implemented Using Jquery. The original code only supports IE. Here I have changed it. There are three versions in my code that implement Author: shaoyun
Email: shaoyun (at) yeah.net
Date: 2010-03-10
Blog: http://shaoyun.cnblogs.com/
Implemented Using Jquery. The original code only supports IE. Here I changed it. There are three versions in my code.
The first one is to build the SDK by reading XML, which supports IE/firefox. chrome does not support it. If you are interested, you can change the XML reading part to AJAX. In this way, chrome support is not a problem.
The second is constructed in Json data format, which is my second attempt to improve
The third and second are actually the same, except that the data is separated into JS files. My Code contains an ASP file that calls the database to generate Json provincial and municipal data, if ASP files are directly called on the page, the speed will be very slow. It is much faster to directly call the JS file after it is generated, and this part of data will not be changed.
Update record:
+ 2010-04-19 12:11:24
An example of adding a plug-in is actually not a plug-in. It is a function. Why not write it into a plug-in? It is just based on flexibility,
So that select can be placed anywhere on the page, rather than limited to page elements such as p, table, and td.
The parameters are similar to the following: s1/s2/s3 sets the select id. v1/v2/v3 is the default value. If you do not want to set this parameter, set it to null or do not set it directly.
The parameter configuration is as follows. Configure the three IDs and default values of select. If no default value is specified, enter null.
The Code is as follows:
Var defaults = {
S1: 'select1 ',
S2: 'select2 ',
S3: 'select3 ',
V1: null,
V2: null,
V3: null
};
This is the fourth example. The php file in the directory is a Demo generated by the server for usage reference.
The data format is defined as follows:
The Code is as follows:
Var threeSelectData = {
"Province": {val: "", items: {"city": {val: "", items: {"district/county ":""}}}},
"Beijing": {val: "01", items :{
"Bj-01": {val: "0101", items :{
"Bj-01-01": "010101"
}},
"Bj-02": {val: "0102", items :{
"Bj-02-01": "010201 ",
"Bj-02-02": "010202"
}}
}},
"Shanxi": {val: "02", items :{}},
"Guangzhou": {val: "02", items :{}}
};
Code example:
The Code is as follows: