Witam, może mi ktoś powiedzieć dlaczego dostaję błąd "Uncaught TypeError: Cannot read property 'addEventListener' of null"?
Pobieram id, próbuję wyświetlić value, ale nie działa.
JS
(function(){
var sIns = document.getElementById('sIns');
function getInsId(){
console.log("test");
};
sIns.addEventListener('onchange', getInsId);
})();
HTML
<div class="col-md-5">
<select id="sIns" class="form-control">
<option value="sAllIns" selected>Rozwiń i wybierz</option>
<?php
foreach($this->zakladki as $instruktor)
{
$id = str_replace('\\', '', $instruktor->id);
$tytulpl = str_replace('\\', '', $instruktor->tytulpl);
?>
<option value="<?php echo $tytulpl;?>"><?php echo $tytulpl;?></option>
<?php
}
?>
</select>
</div>
Potrzebuję pobrać nazwę wybraną w seletcie. Robiłem podobną rzecz i nie było problemu, teraz nie mogę pobrać value.