Skip to content
Advertisement

Is there a way to execute a Javascript function when 2 separate HTML and elements are chosen by the user?

I’m new to Javascript and am struggling to execute a function when two separate elements are selected. I’m trying to get a final result based on the options selected. I work in a logistics company and am just trying out something to practice coding and help in my job. Please see my code below, hope it makes some sense on what i’m trying to achieve (finding out what shipping container is required based on the dimensions of a ‘Kit’). I want to keep the Javascript in a separate file so please bare this in mind when replying.

JavaScript

Advertisement

Answer

You could add event listeners to both selects. In both you point to the same function. In that function, check if both selects have valid values. If so, execute the code.

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