开发者社区> 问答> 正文

请问 如何用json做下拉菜单联动?

想做一个下拉菜单联动,后台给了一个json格式的URL。
不太会用,求指教。

[{"id":1,"majorname":"\u8ba1\u7b97\u673a","parentmajor":0,"hidden":0,"submajor":[{"id":2,"majorname":"\u67b6\u6784\u8bbe\u8ba1","parentmajor":1,"hidden":0},{"id":3,"majorname":"\u8f6f\u4ef6\u5f00\u53d1","parentmajor":1,"hidden":0},{"id":4,"majorname":"\u7f51\u7edc\u8fd0\u7ef4","parentmajor":1,"hidden":0},{"id":5,"majorname":"\u7535\u5b50\u5546\u52a1","parentmajor":1,"hidden":0}]},{"id":6,"majorname":"\u7ecf\u6d4e\u91d1\u878d","parentmajor":0,"hidden":0,"submajor":[{"id":7,"majorname":"\u5bf9\u5916\u7ecf\u6d4e\u8d38\u6613","parentmajor":6,"hidden":0}]}]

<div class="col-xs-12">
<label>专业</label>
<select  class="selectpicker form-control" ></select>
</div>

展开
收起
爵霸 2016-03-05 08:39:03 2335 0
1 条回答
写回答
取消 提交回答
  • 写个伪代码

    for item in items {
       $('select').html(<option value="{item.id}">{item.majorname}</option>) 
    }
    2019-07-17 18:52:50
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载