Intresseanmälan till eventuell ledig platsITdr Grp2024-12-04T17:27:02+01:00
function removeNewlines(text) {
return text.replace(/\n/g, " ");
}
document.addEventListener('DOMContentLoaded', function () {
var now = new Date();
var dateString = now.toLocaleDateString('sv-SE');
var hiddenField = document.querySelector('input[name="ansokningsdatum"]');
if (hiddenField) {
hiddenField.value = dateString;
}
var textarea = document.getElementById('anledning_till_onskat_byte');
if (textarea) {
textarea.addEventListener('blur', function() { this.value = removeNewlines(this.value); });
}
const selectBoxes = ["onskat_program_val", "onskat_program_val_2", "onskat_program_val_3"];
function updateOptions() {
// Gather current selections
const selectedValues = selectBoxes.map((id) => document.getElementById(id).value);
// Reset all options to enabled
selectBoxes.forEach((id) => {
const selectBox = document.getElementById(id);
Array.from(selectBox.options).forEach((option) => {
option.disabled = false;
});
});
// Disable selected options in other boxes, except empty option
selectBoxes.forEach((id) => {
const selectBox = document.getElementById(id);
Array.from(selectBox.options).forEach((option) => {
if (option.value === "" && selectedValues.filter(val => val === "").length {
const selectBox = document.getElementById(id);
Array.from(selectBox.options).forEach((option) => {
if (!selectedValues.includes(option.value)) {
option.disabled = false;
}
});
});
}
// Add change event listeners to all select boxes
selectBoxes.forEach((id) => {
document.getElementById(id).addEventListener("change", updateOptions);
});
// Initialize options on load
updateOptions();
});


