aspnetguy Posted April 11, 2006 Share Posted April 11, 2006 So I want to assign a onchage event to my object, i tried this var SelectBox = new DropDownList(document.getElementById('selectList'));function DropDownList(obj){ this.Items = obj.options; ... this.onchange = function(){}} but it thinks I am trying to create a onchange method for the object.so I tried this var SelectBox = new DropDownList(document.getElementById('selectList'));function DropDownList(obj){ this.Items = obj.options; ... obj.onchange = function(){this.SelectedIndex = obj.selectedIndex}} But in this context (inside the onchange function) this is refering to the obj because I am defining the onchange for obj and obj (select tag) does not have SelectedIndexIs there a way to attach an onchange event (or an event for that matter) to the object (this.onchange) Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 11, 2006 Share Posted April 11, 2006 Use document.obj.onchange? If I understand you correctly. :S Link to comment Share on other sites More sharing options...
Little Goat Posted April 11, 2006 Share Posted April 11, 2006 why dont you just add an onchange attribute?LG Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 11, 2006 Share Posted April 11, 2006 He has: obj.onchange = function(){this.SelectedIndex = obj.selectedIndex}See? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now