I added a dropdownlist using seblod extension in joomla. But the javascript is not working for this.
<html>
<head>
<script type="text/javascript">
alert('onload');
document.getElementById('countrynames').addEventListener('change',function(){
alert('Hello');
});
</script>
</head>
<body>
<select size="1" class="inputbox select " name="countrynames" id="countrynames">
<option selected="selected" value="">- Select an option -</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</body>
</html>
Move your script to the bottom of the page – after the DOM element you’re binding the listener to.
DEMO
JS: