40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
|
//
|
||
|
//Generated by: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-04-05 11:17:38
|
||
|
//
|
||
|
$(document).ready(function() {
|
||
|
});
|
||
|
|
||
|
// Initialize multiselect with existing text values
|
||
|
function initMultiselect() {
|
||
|
const multiselect = document.getElementById('CountrySelect_select');
|
||
|
const textInput = document.getElementById('AccumCountryCodes_text');
|
||
|
|
||
|
// Split text input values and select corresponding options
|
||
|
textInput.value.split(',').forEach(value => {
|
||
|
const option = Array.from(multiselect.options).find(opt => opt.value === value.trim());
|
||
|
if (option) option.selected = true;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
// Update text input when multiselect changes
|
||
|
function updateTextInput() {
|
||
|
const multiselect = document.getElementById('CountrySelect_select');
|
||
|
const textInput = document.getElementById('AccumCountryCodes_text');
|
||
|
|
||
|
// Get selected values as comma-separated string
|
||
|
const selectedValues = Array.from(multiselect.selectedOptions)
|
||
|
.map(option => option.value)
|
||
|
.join(',');
|
||
|
|
||
|
textInput.value = selectedValues;
|
||
|
}
|
||
|
|
||
|
// Initialize on page load
|
||
|
document.addEventListener('DOMContentLoaded', () => {
|
||
|
initMultiselect();
|
||
|
|
||
|
// Add change listener to multiselect
|
||
|
document.getElementById('CountrySelect_select')
|
||
|
.addEventListener('click', updateTextInput);
|
||
|
});
|