samedi 10 octobre 2020

if check box is checked then get product name and price in a array

If check boxed is checked i want to get service name and its price in array.enter image description here Image is also given below: To get values of selected items (i.e service name and it's price in array). Please tell how can I get.

$(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);
            }
        });


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire