onChange help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

onChange help

Post 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?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't recall any event firing when Javascript itself modifies a field. Why not fire the event yourself?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post 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!
Post Reply