How do I create when the data is already selected and exists in the database. Data from this option is disabled. Here I am using laravel 5.7.
jquery to save
$(document).on( 'click', '.savepilihan', function(e){ e.preventDefault(); let tr = $(this).closest('tr'); let td = $(this).closest('td'); let input = $($(tr).find('input')[0]); if(input.val() == '') { Swal.fire({ type: 'error', title: 'Oops...', text: 'Nilai kolom "Pilihan" tidak boleh kosong', }); } else { $(this).hide(); $(td).children("button.deletepilihan").show(); $(tr).addClass('saved'); dataSelect2.push({ id: input.attr("name"), text: input.val(), disabled: false }); $('.select2').select2({ placeholder: "Pilih Jawaban", data: dataSelect2 }).trigger('change'); $(input).attr('readonly', 'readonly'); $(input).css("background-color", "#aaaaaa"); } }); So when you enter the edit page, the options from select will be disabled immediately.
https://stackoverflow.com/questions/67259902/disable-selected-chosen-options-when-it-exists-in-database-laravel April 26, 2021 at 09:49AM
没有评论:
发表评论