Select tag drop down list of secondary linkage cascaded instance code

  • 2020-03-30 01:38:51
  • OfStack

First, from the server side, bind the drop-down list, the text name of the second-level drop-down is named according to certain rules plus the ID of the first-level drop-down.

var options=new Array();
        //The secondary linkage
            options[i]='<option value="'+$(this).val()+'">'+$(this).text()+'</option>';
        });//Put the option list into the array
        $('#ddlPages option:gt(0)').remove();    //Clear the drop-down
        $('#ddlSubsystems').bind('change',function(){        //Register event
            var systemname=$('#ddlSubsystems option:selected').text();
            for(var j=0;j<options.length;j++){
            }    //The option list is initialized first
            $('#ddlPages option:gt(0)').each(function(i){    //Traverse ruled out
                var textname=$(this).text();
                var index=textname.indexOf('-'+systemname);
            $('#ddlPages').val(0);                            //The first row is selected by default

Related articles: