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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top