applicant-site/resources/views/admin/catalog/direction/edit_script.blade.php

90 lines
4.1 KiB
PHP
Raw Permalink Normal View History

<script type="module">
let i = 0;
$('#add').click(function () {
--i;
$('#entrance-examination').append(
`<div class="row field">
<div class="col">
<div class="mt-3">
<label for="entrance-examination[${i}][examination_type_id]">Тип экзамена</label>
</div>
<div class="mt-1">
<select class="form-select" id="entrance-examination[${i}][examination_type_id]"
name="entrance-examination[${i}][examination_type_id]">
@foreach($examination_types as $value => $type)
<option value="{{ $value }}">{{ $type }}</option>
@endforeach
</select>
</div>
<div>
</div>
</div>
<div class="col">
<div class="mt-3">
<label for="entrance-examination[${i}][subject_id]">Предмет</label>
</div>
<div class="mt-1 col">
<select class="form-select" id="entrance-examination[${i}][subject_id]"
name="entrance-examination[${i}][subject_id]">
@foreach($subjects as $value => $subject)
<option value="{{ $value }}">{{ $subject }}</option>
@endforeach
</select>
</div>
<div>
</div>
</div>
<div class="col">
<div class="mt-3">
<label for="entrance-examination[${i}][subject_type_id]">Тип предмета</label>
</div>
<div class="mt-1 col">
<select class="form-select" id="entrance-examination[${i}][subject_type_id]"
name="entrance-examination[${i}][subject_type_id]">
@foreach($subjectTypes as $value => $subjectType)
<option value="{{ $value }}">{{ $subjectType }}</option>
@endforeach
</select>
</div>
<div>
</div>
</div>
<div class="col">
<div class="mt-3">
<label for="entrance-examination[${i}][scores]">Кол-во баллов</label>
</div>
<div class="mt-1 col">
<input class="form-control" name="entrance-examination[${i}][scores]" type="text" value=""
id="entrance-examination[${i}][scores]">
</div>
<div>
</div>
</div>
<div class="col">
<div class="mt-3">
<label for="entrance-examination[${i}][position]">Позиция</label>
</div>
<div class="mt-1 col">
<input class="form-control" name="entrance-examination[${i}][position]" type="text" value=""
id="entrance-examination[${i}][position]">
</div>
<div>
</div>
</div>
<div class="col align-items-end">
<div class="mt-3">
<label for="btn">Действия</label>
</div>
<button type="button" class="btn btn-danger col remove-examination-row" data-id="${i}">Удалить</button>
</div>
</div>`
);
});
$(document).on('click', '.remove-examination-row', function () {
let id=$(this).data('id');
console.log(id);
$('.ffff').append('<input type="hidden" name="delete['+id+']">')
$(this).parents('.field').remove();
});
</script>