velocity 的js里面循环对象使用#foreach

来源:互联网 发布:人工智能雄帝科技 编辑:程序博客网 时间:2024/06/06 17:54
<script>
       function changeSuggestionType(typeid){
        var html="";
        #foreach($types in ${myAccountDTO.suggestionIdeaCommand.types})
          if(typeid==${types.suggestionType.suggestionTypeId}){
                if('${types.typeSubDTOList}'=='[]'){
                    html+='<select style="width:200px"><option value="0">#springMessage("vm.myaccount.ideadeselect")</option></select>';
                }else{
                    var index=false;
                    #foreach($typesubDTO in ${types.typeSubDTOList})
                        if(index)
                            html+='<select style="width:200px;margin-left:100px;" name="suggestionIdeaCommand.suggestionIdeaDTO.suggestionTypeSubId">';
                        else
                            html+='<select style="width:200px" name="suggestionIdeaCommand.suggestionIdeaDTO.suggestionTypeSubId">';
                        html+='<option value="0">#springMessage("vm.myaccount.ideadeselect")</option>';
                        #foreach($typesub in ${typesubDTO.suggestionTypeSubList})
                            html+='<option value="${typesub.suggestionTypeSubId}">${typesub.name}</option>';
                        #end
                        html+='</select><br><br>';
                        index=true;
                    #end
                }
            }        
        #end

        document.getElementById("showtypesub").innerHTML = html;
    }
</script>
0 0
原创粉丝点击