{% extends "layout.html" %} {% block title %}{{ title }}{% endblock %} {% block content %}
{{ breadcrumbs.breadcrumb_header( title=title, submit_button=True ) }}
{% endblock %} {% block script %} const brandInput = document.querySelector('#brandInput'); const brandList = document.querySelector('#brandList'); const addBrandButton = document.querySelector('#addBrandButton'); const removeBrandButton = document.querySelector('#removeBrandButton'); brandInput.addEventListener('input', () => { addBrandButton.disabled = brandInput.value.trim() === ''; }); brandList.addEventListener('change', () => { removeBrandButton.disabled = brandList.selectedOptions.length === 0; }); function sortOptions() { const options = Array.from(brandList.options); options.sort((a, b) => a.text.localeCompare(b.text)); brandList.innerHTML = ''; options.forEach(option => brandList.appendChild(option)); } let tempIdCounter = -1; function addBrand() { const newBrand = brandInput.value.trim(); if (newBrand) { const option = document.createElement('option'); option.textContent = newBrand; option.value = tempIdCounter--; brandList.appendChild(option); brandInput.value = ''; addBrandButton.disabled = true; sortOptions(); } } function removeSelectedBrands() { Array.from(brandList.selectedOptions).forEach(option => option.remove()); removeBrandButton.disabled = true; } {% endblock %}