js select级联,上面分类,下面是内容

js select级联,上面分类,下面是内容

 js select级联,上面分类,下面是内容。

js级联效果如下:

 html和js代码如下:

      <html>  
    <head>
        <title>js select级联,上面分类,下面是内容</title>
        <meta http-equiv="Content-Type" content="text/html;charset=GBK"/>        
    </head>  
    <body>  
      
                <div>
                    <label for="form-field-select-1">分类:</label>
                    <select class="form-control" onchange="changeType(this)">
                        <option value="">请选择</option>                            
                            <option value="1">水果</option>                
                            <option value="2">蔬菜</option>        
                            <option value="3">其他</option>                            
                    </select>
                </div>
                <div>
                    <label for="form-field-select-1">内容:</label>
                    <select ,waItemsJson[i].item_name,waItemsJson[i].item_name);
        }
    }
}

/**
 * 删除objId下所有的options
 */
function removeAll(objId){
    var obj=document.getElementById(objId);
    obj.options.length=0;
}
/**
 * objId下 添加 option
 */
function addOption(objId,text,value){
    var obj=document.getElementById(objId);
    obj.options.add(new Option(text,value)); //这个兼容IE与firefox
}
</script>
    
    </body>  
    </html>