After a bit of bashing my head against the wall and giving it some rest, I decided to just put everything in the onchange
of the html and work with the value obtained from the select itself (this.value
) instead of retrieving it to the app.js since I could not figure out for the life of me a way of doing it with the aforementioned changeLang()
function in js file.
var direction = this.value;
this.value = this.options[0].value;
location = direction;
It is a bit lazy, but it is a good workaround. Thanks to @UmairSarfraz for the response (I did not realize the thing with the onchange
attribute) since it helped me to get to a solution.
PS: Turns out there was indeed someone with a problem the same as mine but I did not find the post at the time of writing this question. Shoutout to the response of @TJCrowder, because not only did he gave the same answer, but also it gave a way of doing that function with an EventListener looking for changes. You can find more details clicking this link