var t = document.getElementById("tree"), obj = { a: 500, b: 1000 }; function f() { var result = (obj[t.value] + 1000); alert(result) } t.onchange = f;