3
Where is the error in this code below that is only returning the state acronym?
window.onload=function(){
var form = document.getElementsByTagName("form")[0];
var cmdEstados = form.Estados;
cmdEstados.onchange=function(){
alert("Sigla: " + this.value + " Estado: " + this.firstChild.nodeValue);
}
}
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8"/>
<title>Página Teste</title>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<body>
<form>
<SELECT name="Estados">
<OPTION value=''>--Selecione--</OPTION>
<OPTION value='CE'>Ceará</OPTION>
<OPTION value='DF'>Distrito Federal</OPTION>
<OPTION value='PB'>Paraíba</OPTION>
<OPTION value='PE'>Pernambuco</OPTION>
<OPTION value='SP'>São Paulo</OPTION>
</SELECT>
</form>
</body>
</html>
Thanks Paulo, it worked!
– Kelly Soares