How to add labels to dropdown menu if the select options are coming from datatables javascript?
How to add labels to dropdown menu if the select options are coming from datatables javascript?
I am using a datatable with dropdown filter for my project where I am popoluating the dropdown menu dynamically from the datatable. Automated 508 complaince tool is throwing the following error for the 3 dropdowns- "Elements with No Accessible Name: (3)". It also provides link to the following site on how to fix the error. https://www.ssa.gov/accessibility/andi/help/alerts.html?no_name_form_element.
I am not sure how to add labels since I am not defining the select options in the HTML. It is coming from Javascipt. Please see the code below. Any guidance will be very helpful. Thanks.
This question has an accepted answers - jump to answer
Answers
Just add the label attribute to the option string built in this loop.
Kevin
Thankyou, I am not a javascript expert. Is this how I add it?
column.data().unique().sort().each(function(d, j) {
select.append('<option value="' + d + '">' + d + '</option>');
select.append('<option label="text">' + d + '</option>');
Please ignore. I figured it out. Thanks for your time.