Js province/municipality drop-down menu

Source: Internet
Author: User

Function GetResult_Load (str, sel)
{
Var oBao = new ActiveXObject ("Microsoft. XMLHTTP ");
OBao. open ("POST", "Relating_Menu_Server.asp? ID = "+ escape (str), false );
OBao. send ();
BuildSel_Load (unescape (oBao. responseText), sel)
}
Function BuildSel_Load (str, sel)
{
Sel. options. length = 0;
If (str! = "")
{
Var Tarrstr = new Array ();
Tarrstr = str. split ("% $ #@")
Strid = Tarrstr [0]
Strname = Tarrstr [1]

Var arrstr1 = new Array ();
Arrstr1 = strid. split (",");
Var arrstr2 = new Array ();
Arrstr2 = strname. split (",");
For (var I = 0; I <arrstr1.length; I ++)
{
Sel. options [sel. options. length] = new Option (arrstr2 [I], arrstr1 [I])
}
}
Var opobj = new Option ("-- select --","")
Sel. add (opobj, 0)
Sel. selectedIndex = 0
}
// Load the first drop-down menu on the page
// Configure //----------------------------------------------------------------------------------------
// Sub-Level Association drop-down menu
// Objname = Name of the current menu
// Nextallobj_str = Name set of the sub-level linkage menu, for example, "Level 1 | level 2 | level 3 | Level 4 | ......"
// Str = required relational parameters passed to the Server for data retrieval
// Nextobj = Name of the associated next menu
// Menu call example: onChange = "GetResult (this. name, 'lower-level | Lower-level ', this. value, document. all. Lower-level )"
Function GetResult (objname, nextallobj_str, str, nextobj)
{
Var yy = new Array ();
Yy = nextallobj_str.split ("| ");
For (var I = 0; I <yy. length; I ++) clearoptions (eval ("document. all." + yy [I]);
Var oBao = new ActiveXObject ("Microsoft. XMLHTTP ");
OBao. open ("POST", "Relating_Menu_Server.asp? ID = "+ escape (str), false );
OBao. send ();
BuildSel (unescape (oBao. responseText), nextobj)
}
Function BuildSel (str, sel)
{
Sel. options. length = 0;
If (str! = "")
{
Var Tarrstr = new Array ();
Tarrstr = str. split ("% $ #@")
Strid = Tarrstr [0]
Strname = Tarrstr [1]

Var arrstr1 = new Array ();
Arrstr1 = strid. split (",");
Var arrstr2 = new Array ();
Arrstr2 = strname. split (",");
For (var I = 0; I <arrstr1.length; I ++)
{
Sel. options [sel. options. length] = new Option (arrstr2 [I], arrstr1 [I])
}
}
Var opobj = new Option ("-- select --","")
Sel. add (opobj, 0)
Sel. selectedIndex = 0
}
Function clearoptions (obj)
{
For (var j = 0; j <= obj. length; j ++) obj. remove (0)
Var opobj = new Option ("-- select --","")
Obj. add (opobj, 0)
Obj. selectedIndex = 0
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.