Adding onChange to Select box value doesn't do anything

J

javelin

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

catid.attributes['onChange'].value= "FilterByCatID();";
alert(catid.attributes['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
 
R

RobG

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

catid.attributes['onChange'].value= "FilterByCatID();";
alert(catid.attributes['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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top