Noobster Noobster - 4 months ago 10x
Javascript Question

Onchange event for multiple dropdowns issue

I have a list like this:

<select id="List_22" >
<option value="default">Default</option>
<option value="1">Oil</option>
<option value="2">Gas</option>
<option value="3">Power</option>

I want to launch a function upon dropdown change, so this works fine:

document.getElementById("List_22").onchange = function() {...

I however have multiple dropdowns that should all use the same function. I have tried to use the below wildcard but it does not work

document.getElementById("[id^=L]").onchange = function() {

What am I doing wrong? I am going slightly barmy. Thank you all for your time.

    $('form select').on('change', function(){

    // Your code here