attaching event handlers to tags with javascript



Say I had <select id="something" name="something"
onchange="demo(this.value)"> but didn't want to define the onchange
event handler in the select tag, itself. ie. I wanted to attach it,
latter, by doing something like...

document.getElementById('something').attachEvent('onchange',demo);

or this:

document.getElementById('something').onchange = demo;

How would I go about passing parameters to demo as I do in the select
tag? Is there a way I could reference this.value in demo without
having to pass it as a parameter to demo?

.



Relevant Pages

  • Re: attaching event handlers to tags with javascript
    ... > yawnmoth wrote: ... >> event handler in the select tag, ... I wanted to attach it, ...
    (comp.lang.javascript)
  • Re: How to modify label.text in a dynamically generated label in VB.net
    ... Your event handler will go something like this: ... If _tag IsNot Nothing Then ... Private Function FindControl(ByVal start As Control, ByVal type as Type, ... When any one of you dynamic CheckBoxes is clicked, ...
    (microsoft.public.dotnet.languages.vb)
  • Adding "onunload" JavaScript event handler to body in code-behind
    ... I am trying to programatically add an "onunload" event handler to the "body" tag of an ASPX page. ... I found out that "runat=server" generates a compilation error if the "body" tag already has an onunload event handler. ... This is a problem, because I wish that the user of my custom control be free to specify event handlers in the body tag, and my control should simply add its own. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: "modern" javascript...
    ... Looking in the source to edit jspf, include, and tag files, or PHP ... As I said before, the event handler attribute ... True if the `script' element is the child of the `head' element. ... ISTM the example showed your idea of a "bottom script" quite well. ...
    (comp.lang.javascript)
  • Re: Question about multi users and using flags
    ... One (custom values with only the value "1") ... a checkbox and attach to it the valuelist "One". ... will show the record as tagged for me if I tag it but it won't be ... carriage return separated and MUST have a carriage return as the last ...
    (comp.databases.filemaker)