Adding onChange to Select box value doesn't do anything

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • javelin

    Adding onChange to Select box value doesn't do anything

    I have this code to add an onChange event to a select control:

    catid.attribute s['onChange'].value= "FilterByCatID( );";
    alert(catid.att ributes['onChange'].value);

    The alert box confirms that the event has been set, but on change of
    the selectbox, nothing happens. Any ideas what I'm missing?

    Thx.

    Jav
  • RobG

    #2
    Re: Adding onChange to Select box value doesn't do anything

    On Apr 17, 10:59 am, javelin <google.1.jvm.. .@spamgourmet.c omwrote:
    I have this code to add an onChange event to a select control:
    >
    catid.attribute s['onChange'].value= "FilterByCatID( );";
    alert(catid.att ributes['onChange'].value);
    >
    The alert box confirms that the event has been set, but on change of
    the selectbox, nothing happens. Any ideas what I'm missing?
    You've created an "onChange" attribute with a string value, what you
    want to do is assign a function to the onchange handler. The most
    reliable way is to set it directly:

    catid.onchange = FilterByCatID;


    Also, it is a convention in javascript that function names starting
    with a captial letter are reserved for constructors.


    --
    Rob

    Comment

    Working...