Hello!
So first thing, I tried using AI to help create this code. It looks alright, but doesnt work at all.
I am trying to lookup data to fill a table, then filter that table based off what is selected on the form. Can anyone assist on why it is not working?
I believe I have all the CSS class's filled out properly.
$(document).ready(function() {
// Store selections
var typeFunctionSelection = '';
var sizeSelection = '';
// Capture type function selection from text box
$('.typeFunctionOption input').change(function() {
typeFunctionSelection = $(this).val();
applyFilter();
});
// Capture size selection (A3 vs A4) from radio buttons
$('input[type=radio].sizeOption').change(function() {
sizeSelection = $(this).val();
applyFilter();
});
function applyFilter() {
if (typeFunctionSelection && sizeSelection) {
$('.deviceTable tr').each(function(index) {
// Skip the header row
if (index === 0) return;
var row = $(this);
var typeFunctionData = row.find('td.typeFunctionColumn').text();
var sizeData = row.find('td.sizeColumn').text();
// Include rows that match both selections or don't have a size listed
if (typeFunctionData.includes(typeFunctionSelection) && (sizeData === sizeSelection || sizeData === '')) {
row.show();
} else {
row.hide();
}
});
}
}
});