【发布时间】:2021-01-25 09:42:25
【问题描述】:
如果选中复选框,我想在数组中获取服务名称及其价格。enter image description here 图片也如下所示: 获取选定项目的值(即服务名称和数组中的价格)。请告诉我如何获得。
$(document).on('click', '.completed_request', function(){
var completed_request_id = $(this).attr('request_id');
var prescription = $(this).parent().parent().find('td').eq(2).text();
console.log((prescription));
var arr_val = prescription.split(',');
if(arr_val != null){
var lihtml = "";
arr_val.forEach(val => {
//lihtml+='<li>'+val+'</li>';
lihtml+='<li><div class="form-check form-check-inline">\n'+
'<input class="form-check-input inlineCheckbox1 checkedId" type="checkbox" value="option1">\n'+
'<label class="form-check-label add" for="inlineCheckbox1" id="">'+val+'</label>\n'+
'</div>';
lihtml+='<input type="text" class="checkedId cal_total checked" id="file_id">\n</li>';
});
// console.log(lihtml);
$("#val_html").html(lihtml);
}
bootbox.confirm("Do you want to complete this request?", function (result) {
if (result == true) {
$('#prescription_names').text(prescription);
$('#completedModalId #request_id').val(completed_request_id);
$('#completedModalId').modal('show');
$('#total_amount').val('');
}
});
});
/*
* to selected item names and price
*/
$(document).on("click", ".checkedId", function() {
if ($('.checkedId').prop('checked') == true) {
//console.log($(this).next('label').text());
var selectedItemsNames = $(this).next('label').text();
//var row = $('.cal_total').closestval();
//$('.cal_total').addClass("checked").removeClass("unchecked");
var checks = [];
var ss = $('.cal_total').each(function(index, item){
checks.push( item );
});
console.log(row);
console.log(selectedItemsNames);
}
});
【问题讨论】:
-
html代码在哪里?
-
在 jquery 中我调用了 html
-
您需要在
json-array或简单数组中获取不同数组中的两个值? -
两个值的简单数组
标签: javascript html jquery jquery-ui laravel-5