function handleCheckboxChange() {
    const checkbox = document.getElementById('defaultCheck1');
    const usernameInput = document.getElementById('username');
    const passwordInput = document.getElementById('password');

    if (checkbox.checked) {
      localStorage.setItem('username', usernameInput.value);
      localStorage.setItem('password', passwordInput.value);
    } else {
      localStorage.removeItem('username');
      localStorage.removeItem('password');
    }
}

function loadStoredValues() {
    const checkbox = document.getElementById('defaultCheck1');
    const usernameInput = document.getElementById('username');
    const passwordInput = document.getElementById('password');

    if (checkbox.checked) {
      const storedUsername = localStorage.getItem('username');
      const storedPassword = localStorage.getItem('password');

      if (storedUsername !== null) {
        usernameInput.value = storedUsername;
      }
      if (storedPassword !== null) {
        passwordInput.value = storedPassword;
      }
    } else {
      usernameInput.value = '';
      passwordInput.value = '';
    }
}

document.getElementById('defaultCheck1').addEventListener('change', handleCheckboxChange);
document.addEventListener('DOMContentLoaded', loadStoredValues);