function handleRedirect() {
    const selectElement = document.getElementById('actions');
    const selectedValue = selectElement.value;
    
    if (selectedValue) {
        window.location.href = selectedValue;
    }
}


document.addEventListener('DOMContentLoaded', function() {
    const toggleButton = document.getElementById('toggle-button');
    const additionalFieldsContainer = document.getElementById('additional-fields-container');
    const addButton = document.getElementById('add-field');
    const removeButton = document.getElementById('remove-field');

    let isFieldsVisible = false;

    // Initially hide the additional fields
    additionalFieldsContainer.classList.add('hidden');

    function toggleFields() {
        isFieldsVisible = !isFieldsVisible;

        if (isFieldsVisible) {
            additionalFieldsContainer.classList.remove('hidden');  // Show the fields
            toggleButton.textContent = 'REMOVE'; // Change button text to REMOVE
        } else {
            additionalFieldsContainer.classList.add('hidden');  // Hide the fields
            toggleButton.textContent = 'ADD';  // Change button text to ADD
        }
    }

    // Handle toggle button click
    toggleButton.addEventListener('click', function(event) {
        event.preventDefault(); // Prevent default anchor behavior
        toggleFields();
    });
});
    // Function to clone and add a new set of fields
//    function addField() {
//        const fieldHTML = additionalFieldsContainer.querySelector('.additional-fields').innerHTML;
//        const newFieldSet = document.createElement('div');
//        newFieldSet.classList.add('additional-fields');
//        newFieldSet.innerHTML = fieldHTML;
//        additionalFieldsContainer.appendChild(newFieldSet);
//    }
//
//    // Function to remove the last set of fields
//    function removeField() {
//        const fieldSets = additionalFieldsContainer.querySelectorAll('.additional-fields');
//        if (fieldSets.length > 1) { // Ensure at least one set remains
//            additionalFieldsContainer.removeChild(fieldSets[fieldSets.length - 1]);
//        }
//    }
//
//    // Event listeners for plus and minus images
//    addButton.addEventListener('click', function(event) {
//        event.preventDefault();  // Prevent default behavior (if required)
//        addField();
//    });
//    
//    removeButton.addEventListener('click', function(event) {
//        event.preventDefault();  // Prevent default behavior (if required)
//        removeField();
//    });
//});


//---------------------DYNAMIC DROPDOWN WHILE SELECTING CONDITION-------------------//
//function toggleSecondDropdown(selectElement) {
//    const secondDropdown = document.getElementById('second-dropdown');
//
//    // Show the second dropdown when SSID or MAC address is selected
//    if (selectElement.value === '1' || selectElement.value === '2') {
//        secondDropdown.style.display = 'block';
//    } else {
//        secondDropdown.style.display = 'none';
//        // Hide the value input if second dropdown is hidden
//        document.getElementById('value-input-group').style.display = 'none';
//    }
//}
//
//function showInputField(selectElement) {
//    const valueInputGroup = document.getElementById('value-input-group');
//
//    // Show the input field when any valid option is selected from the second dropdown
//    if (selectElement.value !== '#' && selectElement.value !== "") {
//        valueInputGroup.style.display = 'block';
//    } else {
//        valueInputGroup.style.display = 'none';
//    }
//}
//