function showSelectedItemForm(sel,id){ var option; var name; var div; Array.from(sel.options).forEach(function(option){ console.log(option); name = 'pridat-'+option.value+'-'+id; div = document.getElementById(name); console.log(div); div.style.display = 'none'; }); name = sel.options[sel.selectedIndex].value; name = 'pridat-'+name+'-'+id; div = document.getElementById(name); console.log(div); div.style.display = 'block'; }