Page 1 of 1

onChange help

Posted: Sun Jul 30, 2006 8:45 pm
by s.dot
I'm using onKeyUp to trigger javascript code after each key is pressed in an input field. However i have a color picker that fills that fills the field with a value when that color is picked.

Doing it that way, neither onKeyUp or onChange triggers the javascript. Is there perhaps another event handler I am looking for?

Posted: Sun Jul 30, 2006 8:53 pm
by feyd
I don't recall any event firing when Javascript itself modifies a field. Why not fire the event yourself?

Posted: Sun Jul 30, 2006 9:00 pm
by s.dot
Well i want to fire it after the javascript has modified the value of the field. Which is where i thought onChange would come in.

Hmm. I think i could try giving the field focus after it has been modified. Then use onFocus to fire it.

Posted: Sun Jul 30, 2006 9:18 pm
by s.dot
Well, that worked. But now onKeyUp doesn't want to fire.

Code: Select all

<input type="text" name="pageBackgroundColor" size="15" onFocus="document.forms[0].submit();" onKeyUp="document.forms[0].submit();">
Is there a way to fire them when either happens?

I want to submit the form after any key is pressed, or after focus.

Posted: Mon Jul 31, 2006 12:00 am
by JAB Creations
There is no "onKeyUp" event in HTML. There is however an "onkeyup" event.

http://www.w3.org/TR/html4/interact/scr ... l#h-18.2.3

It is case sensitive when within the HTML itself. This however may or may not effect such a low level of HTML as you're not using XHTML (your input was not closed).

Best of luck!