
- Introduced worklog form fields for start and end timestamps, contact, work item, completion status, follow-up, analysis, and notes. - Updated worklog.html to include a save button and improved layout. - Enhanced datalist.js for dynamic data binding between input fields and datalists. - Refactored inventory.html and user.html for consistency and readability. - Added form.html template for future use.
20 lines
713 B
JavaScript
20 lines
713 B
JavaScript
document.querySelectorAll('[data-datalist-bind]').forEach(input => {
|
|
const datalistSelector = input.dataset.datalistBind;
|
|
const hiddenSelector = input.dataset.hiddenTarget;
|
|
const datalist = document.querySelector(datalistSelector);
|
|
const hidden = document.querySelector(hiddenSelector);
|
|
|
|
if (!datalist || !hidden) return;
|
|
|
|
input.addEventListener('input', function () {
|
|
const value = this.value;
|
|
const options = datalist.querySelectorAll('option');
|
|
let foundId = '';
|
|
options.forEach(option => {
|
|
if (option.value === value) {
|
|
foundId = option.dataset.id || '';
|
|
}
|
|
});
|
|
hidden.value = foundId;
|
|
});
|
|
});
|