471,886 Members | 1,086 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,886 software developers and data experts.

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 1380
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.