SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What's the easiest way to bind an onchange-event to a control inside a custom-form of my custom list? Just writing it into is not possible.

Changing the controls value should start some functions to hide other controls and something like this.

Is the easiest way to use Javascript and select it in DOM? Or another idea...... Can I attach a codebehind file and do the same?

It would be great, if somebody can help me.

Thanks in advance


share|improve this question
up vote 0 down vote accepted

You can certainly do it with Javascript as you suggested. Either with straight Javascript, or with jQuery. Something like $("#elemID").change() will essentially bind the change event to the element. You could store the script in a codebehind file, but I believe you'd still need some sort of client side script, al la Javascript to detect the change at the client side.

share|improve this answer
That's the solution I'm trying at the moment. I've got a problem with this. When the scripts starts up, I don't know the ID's of the elements I want to bind the event to. So I can't write something like $("#elemID").change() because I get the ID's just at runtime. I'm using another function that looks them up by a selection of their tag's title, but this doesn't really help me in this case. – user1832 Nov 12 '10 at 15:52
I do this on custom forms and you can do it even at runtime. Instead of using the #elemID , you can use the the type of element something like this: $("select[id*='someid']").change() The someid is any part of the id you know is unique. You can find this with a DOM inspector – spevilgenius Nov 14 '10 at 14:41
Are you saying you don't know the title, or the title method isn't working for you? I've seen the "function" floating around that finds the element by title for you. Just FYI, you can do it much simpler with straight jQuery $('select[title=Your_Title]').change(); You'd also want to make sure you encapsulate that in a $(document).ready(); function so that it doesn't try to fire until after the DOM has been built. – webdes03 Nov 15 '10 at 17:14
Thanks for your answers. I hoped there is an easier way to solve it, but now I know, what's the right way to handle this. – user1832 Nov 16 '10 at 11:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.