I want to make it so that when I click on one of the dropdowns, a value based on the record ID from the related table appears immediately. I want to make it so that when I click on one of the dropdowns, a value based on the record ID from the related table appears immediately. When "golongan" is selected, the value of "gaji pokok" automatically appears. When "asisten ahli" is selected, the value for "tunjangan fungsional" appears automatically. When "Chairman Assistant | Expert Assistant" is selected, the value of "Structure Allowance" automatically appears.
<div class="modal fade" id="tambahgajiModal" tabindex="-1" role="dialog" aria-labelledby="tambahgajiModal" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="tambahfungsiModal">Tambah Gaji Karyawan</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form action="/gaji/insert" method="POST" enctype="multipart/form-data"> @csrf <div class="content"> <div class="row"> <div class="col-sm-12"> <div class="form-group"> <select name="nama" type="text" class="form-control select2 @error('nama') is-invalid @enderror" value="{{ old('nama') }}"> <option>-- Nama Karyawan --</option> @foreach ($karyawan as $data) <option value="{{ $data->nama }}">{{ $data->nama }}</option> @endforeach </select> <div class="invalid-feedback"> @error('nama') {{ $message }} @enderror </div> </div> <div class="form-group"> <select name="gol" type="text" class="form-control select2 @error('gol') is-invalid @enderror" onchange="getddl()" value="{{ old('gol') }}"> <option>-- Golongan dan M K G --</option> @foreach ($golongan as $data) <option value="{{ $data->gol }} | {{ $data->mkg }}">{{ $data->gol }} | {{ $data->mkg }}</option> @endforeach </select> <div class="invalid-feedback"> @error('gol') {{ $message }} @enderror </div> </div> <div class="form-group"> <input name="tunjangan_gol" type="text" placeholder="Gaji Pokok" class="form-control @error('tunjangan_gol') is-invalid @enderror" value="{{ old('tunjangan_gol') }}" id="gol"> <div class="invalid-feedback"> @error('tunjangan_gol') {{ $message }} @enderror </div> </div> <div class="form-group"> <select name="jbt_fungsi" type="text" class="form-control select2 @error('jbt_fungsi') is-invalid @enderror" value="{{ old('jbt_fungsi') }}"> <option>-- Jabatan Fungsional --</option> @foreach ($fungsi as $data) <option value="{{ $data->jbt_fungsi }}">{{ $data->jbt_fungsi }}</option> @endforeach </select> <div class="invalid-feedback"> @error('gol') {{ $message }} @enderror </div> </div> <div class="form-group"> <input name="tunjangan_fungsi" type="text" placeholder="Tunjangan Fungsional" class="form-control @error('tunjangan_fungsi') is-invalid @enderror" value="{{ old('tunjangan_fungsi') }}"> <div class="invalid-feedback"> @error('tunjangan_fungsi') {{ $message }} @enderror </div> </div> <div class="form-group"> <select name="jbt_struktur" type="text" class="form-control select2 @error('jbt_struktur') is-invalid @enderror" value="{{ old('jbt_struktur') }}"> <option>-- Jabatan Struktural & Fungsional --</option> @foreach ($struktur as $data) <option value="{{ $data->jbt_struktur }} | {{ $data->jbt_fungsi }}">{{ $data->jbt_struktur }} | {{ $data->jbt_fungsi }}</option> @endforeach </select> <div class="invalid-feedback"> @error('jbt_struktur') {{ $message }} @enderror </div> </div> <div class="form-group"> <input name="tunjangan_struktur" type="text" placeholder="Tunjangan Struktural" class="form-control @error('tunjangan_struktur') is-invalid @enderror" value="{{ old('tunjangan_struktur') }}"> <div class="invalid-feedback"> @error('tunjangan_struktur') {{ $message }} @enderror </div> </div> <div class="form-group"> <input name="total_gaji" type="text" placeholder="Total Gaji" class="form-control @error('total_gaji') is-invalid @enderror" value="{{ old('total_gaji') }}"> <div class="invalid-feedback"> @error('total_gaji') {{ $message }} @enderror </div> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Save</button> </div> </form> </div> </div> </div>
How to use Javascript onChange for packaging in laravel?
Sorry, I don't understand your language very well, but you can do something like this with jquery
You can leave the dependency dropdown empty and then get these dependency dropdowns via ajax like this:
And declare in ajax the route you will call in the url
Perform the following operations in the controller: