Added onchange event in javascript instead of HTML