在jsp页面中,通过异步请求,返回的list集合,需要循环添加到select下拉框中,如下:
$("#fundCode").change(function(){
var fundCode = $(this).val();
var financeAcc = $("#financeAcc2").val();
$.ajax({
url: "${pageContext.request.contextPath}/admin/convert/convertJson",
type: 'GET',
contentType: 'application/json',
data:{fundCode: fundCode,financeAcc:financeAcc},
success: function(result) {
$("#allowtradeVol").val(result.map["allowtradeVol"]);
$("#shortName").val(result.map["shortName"]);
var fundRiskLevel = result.map["riskLevels"];
var riskLevelx = $("#riskLevel2").val();
$("#fundRiskLevel").value = fundRiskLevel;
if(parseInt(fundRiskLevel) != parseInt(riskLevelx)){
$("#aDiv").show();
}
var convertLists = result.convertList;
$.each(convertLists, function (i, item) {
jQuery("#targetFundCode").append("<option value="+item.value+">"+item.label+"</option>");
});
},
});
});
select下拉框标签:
<div class="span6 box">
<label class='control-label'>转入基金</label>
<div class='controls'>
<select class='input-block-level' name="targetFundCode" id='targetFundCode' ">
</select>
</div>