Skip to content
Advertisement

Get values from two select element and compare in another function

I’m trying to get two values from different select elements and access those elements outside a function.

JavaScript

when I log my function it just returns the first value it does not change when you select another option. What would be a way I can compare values and to a certain thing

https://jsfiddle.net/v50wdnL1/1/ I included a jsfiddle

Advertisement

Answer

Not quite sure why the #onchange events are calling function that only return values and dont do any meaningful operations. Instead make them both call a compare function and in that compare function call your other function which return the values. Example below:

HTML:

JavaScript

JavaScript:

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