weui的下拉框的赋值与取值
2018年08月07日 10:35:32 夏天wx:a1024271896 阅读数:700 标签: weui下拉框 更多
个人分类: 技术类文章
版权声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 https://blog.csdn.net/a1024271896/article/details/81476768
weui相关问题
页面代码:
-
<div id="search_box" class="input_center_box">
-
<div id="search_xq" class="input_center_box">
-
<div id="all_sflb" class="dly_select" data-action=""></div>
-
</div>
-
</div>
样式:
-
.dly_select{
-
width:calc(80% - 0.5% );
-
height:2rem;
-
border:1px solid #1AAD19;
-
margin:0.65rem auto;
-
padding-left:10px;
-
box-sizing:border-box;
-
font-size:0.8rem;
-
border-radius:5px;
-
color:#666;
-
line-height:2rem;
-
}
-
.dly_select{
-
background: transparent;
-
background: url(${pageContext.request.contextPath}/resources/hit/images/app/kscx/icon_xiala.png) no-repeat;
-
background-position: 95% center;
-
background-size:0.8rem 0.5rem;
-
line-height:2rem;
-
color:#666;
-
}
给下拉框赋值的方法:
//weui的身份类别下拉框赋值
-
$.ajax({
-
url : "${pageContext.request.contextPath}/fwdt/dengluye/listSflb",
-
type : "GET",
-
contentType : "application/json",
-
success: function(result){
-
result = JSON.parse(result).module;
-
// console.log(result)
-
var v_arry = [];
-
var arryszqx = [];
-
arryszqx.push(result[0].lbdm);
-
$("#all_sflb").text(result[0].lbmc);
-
$("#all_sflb").attr("data-action",result[0].lbdm);
-
for(var i=0;i<result.length;i++){
-
var v_data = {
-
label : result[i].lbmc,
-
value : result[i].lbdm
-
}
-
v_arry.push(v_data);
-
$("#search_xq").click(function(){
-
weui.picker(v_arry, {
-
defaultValue: arryszqx,
-
onChange: function (result) {
-
$("#all_sflb").text(result[0].label);
-
$("#all_sflb").attr("data-action",result[0].value);
-
},
-
onConfirm: function (result) {
-
$("#all_sflb").text(result[0].label);
-
$("#all_sflb").attr("data-action",result[0].value);
-
},
-
id: 'search_xqpicker'
-
});
-
});
-
}
-
},
-
});
取出weui下拉列表的值的方法:
//获取下拉列表中的身份类别的id
var lbdm = $("#all_sflb").attr("data-action");
页面:
转自https://blog.csdn.net/a1024271896/article/details/81476768