Home  >  Article  >  Web Front-end  >  How to achieve select select secondary linkage effect

How to achieve select select secondary linkage effect

一个新手
一个新手Original
2017-09-22 09:00:103304browse

<li style="margin-right:-5px">一级类目:
                    <select id="mainCategoryId" name="mainCategoryId" class="length_2" onchange="changeCate()">
                        <option value="">---请选择---</option>
                        #foreach($cell in $categories)
                            <option value="$!{cell.id}"  #if($!cell.id ==  $!query.mainCategoryId) selected #end >$!{cell.name}</option>
                        #end
                    </select>
                </li>
                <li style="margin-right:-5px">二级类目:
                    <select class="categoryId" name="categoryId" class="length_2">
                        <option value="">---请选择---</option>
                    </select>
                </li>

function changeCate(){    
 var  mainCategoryId = 
$("#mainCategoryId").find("option:selected").val();   
 if(mainCategoryId == "") {        
 $(".categoryId").empty().append("520dd156c44cb6a5aae38550b5c48a0b---请选择---4afa15d3069109ac30911f04c56f3338");        
 return false;
    }    
 $.ajax({       
     url:'/tvtao/video/item/category.htm',        
     type:"post",        
     dataType:"json",        
     data: {'_tb_token_' : $("input[name='_tb_token_']").val(), parantId : mainCategoryId},        
     success: function (data) {            
     console.log(data);            
     $(".categoryId").empty().append("520dd156c44cb6a5aae38550b5c48a0b---请选择---4afa15d3069109ac30911f04c56f3338");           
      for(var i = 0, len = data.length; i 78ac66e8ecf169eea75a9dee23087133" + data[i].name + "4afa15d3069109ac30911f04c56f3338"));
            }

        }
    });
}

The above is the detailed content of How to achieve select select secondary linkage effect. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn