Skip to content
Advertisement

How can I load this select input field with options passed using JS?

When loading an HTML table, there is this select input field, which should make available some options. Right after the HTML table row is built, I’m calling a function, which should populate this input field, getting it by its class.

Here is the HTML piece and the function:

JavaScript
JavaScript

Appreciate any help!

Advertisement

Answer

Your selectors for .querySelector('tableBodySelect') doesn’t match your desired elements. You try to match the classes, therefore you need to prepend a . to your selector .querySelector('.tableBodySelect')

This does already resolve your issue.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement