Demo1 for the simplest implementation, page ID configuration needs to be written in the JS file, suitable for simple situations
Demo2 added dynamic configuration, you can pass the configuration entry, suitable for the page exists multiple cascading dropdown
The following is the city data JSON format, you can use Ajax to obtain or make ashx/asmx services can also be directly saved as a JS file, according to your city data adjustment format, and modify the corresponding source code
Copy Code code as follows:
var _ds_data=[
{
id:0,
Name: "\u5317\u4eac",
city:[
{
Id:1,
Name: "\u5317\u4eac\u5e02",
Area:[{id:1,name: "\u4e1c\u57ce\u533a"},{...},{...} ...]
},...]
}
To prevent garbled code, the Unicode encoding is used and the conversion codes are as follows:
Copy Code code as follows:
<summary>
Converts the original string to Unicode, in the form of \u....\u ....
</summary>
public static string Stringtounicode (String srctext)
{
string dst = "";
char[] src = srctext.tochararray ();
for (int i = 0; i < src. Length; i++)
{
byte[] bytes = Encoding.Unicode.GetBytes (src[i). ToString ());
String str = @ "\u" + bytes[1]. ToString ("X2") + bytes[0]. ToString ("X2");
DST + + str;
}
return DST;
}
<summary>
\u....\u Unicode string .... format string converted to original
</summary>
public static string Unicodetostring (String srctext)
{
string dst = "";
string src = srctext;
int len = SRCTEXT.LENGTH/6;
for (int i = 0; I <= len-1; i++)
{
String str = "";
str = src. Substring (0, 6). Substring (2);
src = src. Substring (6);
byte[] bytes = new Byte[2];
Bytes[1] = byte. Parse (int. Parse (str. Substring (0, 2), Numberstyles.hexnumber). ToString ());
Bytes[0] = byte. Parse (int. Parse (str. Substring (2, 2), Numberstyles.hexnumber). ToString ());
DST + + Encoding.Unicode.GetString (bytes);
}
return DST;
}
Http://xiazai.jb51.net/201002/yuanma/cityselector.rar
Package Download Address