First from the server side, bind the Drop-down list, the level two drop-down of the text name according to a certain rule plus the first level Drop-down ID.
Copy Code code as follows:
var options=new Array ();
$ (document). Ready (function () {
Two-level linkage
$ (' #ddlPages '). Children (' option '). each (function (i) {
options[i]= ' <option value= ' +$ (This). Val () + ' > ' +$ (This). Text () + ' </option> ';
);//place option list in array
$ (' #ddlPages option:gt (0) '). Remove (); Clear down, pull.
$ (' #ddlSubsystems '). Bind (' Change ', function () {//Register event
var systemname=$ (' #ddlSubsystems option:selected '). Text ();
for (Var j=0;j<options.length;j++) {
$ (' #ddlPages '). Append (Options[j]);
The//option list is initialized first
$ (' #ddlPages option:gt (0) '). each (function (i) {//Traversal exclusion
var textname=$ (this). text ();
var index=textname.indexof ('-' +systemname);
if (index<0) {
$ (this). Remove ();
}else{
$ (this). Text (textname.substring (0,index));
}
});
$ (' #ddlPages '). val (0); The first row is selected by default
});
});