469,352 Members | 1,677 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Adding onChange to Select box value doesn't do anything

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
Jun 27 '08 #1
1 1334
On Apr 17, 10:59 am, javelin <google.1.jvm...@spamgourmet.comwrote:
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.
--
Rob
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Mattias Campe | last post: by
3 posts views Thread by daveland | last post: by
1 post views Thread by Jan Doggen | last post: by
1 post views Thread by The Eclectic Electric | last post: by
4 posts views Thread by ballygowanboy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.