Merge pull request #37 from arieeefajar/fix/assessment-form

fix(assessment-form): add description in input value parameter
This commit is contained in:
Arie Fajar Bachtiar 2025-04-22 15:22:11 +07:00 committed by GitHub
commit 195a91e9f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -1,2 +1,9 @@
var landField = document.getElementById("lahan-field");
var landVal = new Choices(landField);
function showInfo(selectEl, id) {
const infoElement = document.getElementById(id + "-info");
const selectedOption = selectEl.selectedOptions[0];
const description = selectedOption.getAttribute("data-desc");
infoElement.innerText = description || "-";
}

View File

@ -50,12 +50,16 @@
<div class="mb-3">
<label for="" class="form-label">{{ $indicator->name }}</label>
<select name="{{ $indicator->id }}" class="form-control"
id="{{ $indicator->id }}-field" required>
id="{{ $indicator->id }}-field" onchange="showInfo(this,{{ $indicator->id }})"
required>
<option value="" selected disabled>Pilih Jawaban</option>
@foreach ($indicator->rules as $rule)
<option value="{{ $rule->cf }}">{{ $rule->parameter_type }}</option>
<option value="{{ $rule->cf }}" title="{{ $rule->description }}"
data-desc="{{ $rule->description }}">
{{ $rule->parameter_type }}</option>
@endforeach
</select>
<small id="{{ $indicator->id }}-info" class="text-muted d-block mt-1"></small>
<div class="invalid-feedback">
Pilih Jawaban {{ $indicator->name }}
</div>