File size: 2,200 Bytes
3c90fc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | document.addEventListener('DOMContentLoaded', function() {
// Family and Type dropdown dependencies
const familyDropdown = document.getElementById('family');
const typeDropdown = document.getElementById('type');
// Product type options based on family
const productTypes = {
mcu: ['8-bit AVR', '8-bit PIC', '16-bit PIC', '32-bit ARM Cortex-M', '32-bit ARM Cortex-A'],
mpu: ['ARM-based', 'MIPS-based', 'RISC-V'],
analog: ['Amplifiers', 'Comparators', 'Data Converters', 'Interface', 'Power Management'],
memory: ['EEPROM', 'Flash', 'SRAM', 'FRAM'],
wireless: ['Bluetooth', 'Wi-Fi', 'LoRa', 'Zigbee', 'NFC']
};
// Update type dropdown based on family selection
familyDropdown.addEventListener('change', function() {
const selectedFamily = this.value;
typeDropdown.innerHTML = '<option value="">Select Type</option>';
typeDropdown.disabled = !selectedFamily;
if (selectedFamily) {
productTypes[selectedFamily].forEach(type => {
const option = document.createElement('option');
option.value = type.toLowerCase().replace(/\s+/g, '-');
option.textContent = type;
typeDropdown.appendChild(option);
});
}
});
// Search button functionality
document.getElementById('search-btn').addEventListener('click', function() {
const family = familyDropdown.value;
const type = typeDropdown.value;
const searchTerm = document.getElementById('search').value.trim();
if (!family && !searchTerm) {
alert('Please select a product family or enter a part number');
return;
}
// In a real app, this would fetch data from Microchip's API
console.log('Searching for:', { family, type, searchTerm });
alert('This would search Microchip\'s database in a real application');
});
// Responsive adjustments
function handleResize() {
// Add any responsive behaviors here
}
window.addEventListener('resize', handleResize);
handleResize();
}); |