Need help with onChange

Discussion in 'Javascript' started by Mel, Apr 5, 2007.

  1. Mel

    Mel Guest

    Warning: Newbeeeeeeeeeee

    I have created my form elements already.
    after form creations i am attempting to add an onChange to one of my
    Select(s) with ID=S100

    here is the code:
    ---------------------------------------------------------
    function onChangeCB(ename,flag,url) {
    alert('onChangeCB');
    }

    function selectCB(ename,flag,url) {
    alert('selectCB');

    document.getElementById(ename).onChange=function()
    {onChangeCB(ename,flag,url);}
    }

    selectCB('S100',1,'http://www.yahoo.com')
    ------------------------------------
    when i reload the page i get the alert 'selectCB' for good reasons,
    but my 'onChangeCB' never gets called. If you can help i truely
    appreciate it
    Mel, Apr 5, 2007
    #1
    1. Advertising

  2. Mel

    Guest

    On Apr 5, 2:37 pm, "Mel" <> wrote:
    > Warning: Newbeeeeeeeeeee
    >
    > I have created my form elements already.
    > after form creations i am attempting to add an onChange to one of my
    > Select(s) with ID=S100
    >
    > here is the code:
    > ---------------------------------------------------------
    > function onChangeCB(ename,flag,url) {
    > alert('onChangeCB');
    >
    > }
    >
    > function selectCB(ename,flag,url) {
    > alert('selectCB');
    >
    > document.getElementById(ename).onChange=function()
    > {onChangeCB(ename,flag,url);}
    >
    > }
    >
    > selectCB('S100',1,'http://www.yahoo.com')
    > ------------------------------------
    > when i reload the page i get the alert 'selectCB' for good reasons,
    > but my 'onChangeCB' never gets called. If you can help i truely
    > appreciate it


    lol funny, i had to actually put this into an HTML and run it myself
    because i couldnt see what the problem was.

    "onchange" has to be all lowercase. if you change it to this it will
    work:

    document.getElementById(ename).onchange= function()
    {onChangeCB(ename,flag,url);}
    , Apr 5, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MDBloemker
    Replies:
    2
    Views:
    2,851
  2. Chris  Ashley

    Onchange event - need to click out?

    Chris Ashley, Dec 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    702
    Karl Seguin
    Dec 6, 2005
  3. Anders S. Clausen
    Replies:
    3
    Views:
    55,339
    ranjithchinnasamy83
    Jan 5, 2009
  4. James Radke

    DropDownList and Client Side OnChange - help!

    James Radke, Oct 6, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,511
    Jeffrey Tan[MSFT]
    Oct 8, 2003
  5. NewmanBT

    need help with onChange event

    NewmanBT, May 17, 2004, in forum: Javascript
    Replies:
    1
    Views:
    147
    NewmanBT
    May 18, 2004
Loading...

Share This Page