我有MultiSelect List&使用Ajax / Json获取数据。我需要将Quantity添加到Selected Products.Here我在Multiselectbox之后放了一个Button.First Select Multiple Products&然后单击我需要将该数据作为Html表加载到Empty div的按钮。
我不知道如何将选定项目添加到Html表(将Html表加载到空div)
这是我的观点
<select id="select-product" multiple style="width: 300px">
// here is MultiSelectbox
</select>
<button class="btn btn-default " id="pick" name="Pick" value="Submit">Pick</button>
<div id="product-load-tbl"></div> <-- need to load table here
这是我的Ajax Call
<script type="text/javascript">
$(function () {
CallMultipleProducts();
$("#select-product").select2({ placeholder: "Select multiple products here", });
});
function CallMultipleProducts() {
$.ajax({
type: "POST",
url: '/Orders/GetMultipleProducts',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (msg) {
if (msg._prodlst.length > 0) {
$.each(msg._prodlst, function (index, item) {
$('#select-product').append($("<option></option>").attr("Value", item.ProductId).text(item.ProductName));
});
}
}
})
}
</script>