I have a button that upon clicking calls a function. I want to make this button disabled inside the function without refereing to its id so I tried to use this.disabled=true; but it doesn't seem to be working. Can't I use "this" to refer to the object that calls a function inside the function?
When calling the function you can pass "this" and the element where the javascript occurs will be passed. The example below works in both ie and firefox: <script language="javascript"> function testThis(obj) { obj.disabled = true; } </script> <input type="button" id="btnDisable" name="btnDisable" value="Disable" onClick="testThis(this);"/>