This article mainly introduces the code of the Select label drop-down list second-level linkage cascade instance. For more information, see bind the drop-down list from the server, the text name of the level-2 drop-down is added with the ID of the level-1 drop-down according to certain rules.
The Code is as follows:
Var options = new Array ();
$ (Document). ready (function (){
// Second-level linkage
$ ('# DdlPages'). children ('option'). each (function (I ){
Options [I] =''+ $ (This). text () +'';
}); // Put the option List in the array
$ ('# DdlPages option: gt (0)'). remove (); // clear the drop-down list
$ ('# DdlSubsystems'). bind ('change', function () {// register an event
Var systemname = $ ('# ddlSubsystems option: selected'). text ();
For (var j = 0; j $ ('# DdlPages'). append (options [j]);
} // The option List is initialized first.
$ ('# DdlPages option: gt (0)'). each (function (I) {// traverse 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.
});
});