Avatar of tr5
tr5
 asked on

onchange event for input text element not firing when changing value

I have a an input element:
<INPUT size=1 TYPE="TEXT" name="no_cat_input" value="0" onChange="calcCats();">

According to what I read about JS events, the function calcCats() should run when i change the text in the field. however it only runs when I change the value AND then click elsewhere to get the focus off the input element. Why is this?

thanks
tr5
JavaScript

Avatar of undefined
Last Comment
tr5

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
neeraj523

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cmalakar

andrux

Because the onChange event fires when you actually made a change to the text box, which happens after the text box loses focus.

neeraj523's answer should work for your case, using onKeyUp or even onKeyDown event.
neeraj523

Dear @tr5

do you need any further assistance on your this question ?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
tr5

ASKER
Thank you.