By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,714 Members | 1,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,714 IT Pros & Developers. It's quick & easy.

Can you do an onchange event when the field was changed through JavaScript?

P: n/a
Here is my issue I have two text fields (Field A, Field B). I want
Field B to be updated when Field A is changed. The problem is Field A
is being changed through JavaScript so an onChange event is not
fired. Is there any way to make this work without having to change
the code that changes Field A?

Thanks,

William

Apr 9 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a
"William Cole" <wr****@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
Here is my issue I have two text fields (Field A, Field B). I want
Field B to be updated when Field A is changed. The problem is Field A
is being changed through JavaScript so an onChange event is not
fired. Is there any way to make this work without having to change
the code that changes Field A?
OK, how about *adding* code to the onchange event of Field A that makes sure Field B
either has the same value, or that just simply makes Field B equal A every time A changes.

-Lost
Apr 9 '07 #2

P: n/a
On Apr 10, 3:38 am, "William Cole" <wrc...@gmail.comwrote:
Here is my issue I have two text fields (Field A, Field B). I want
Field B to be updated when Field A is changed. The problem is Field A
is being changed through JavaScript so an onChange event is not
fired. Is there any way to make this work without having to change
the code that changes Field A?
For all practical purposes, no. A couple of options are to do the
onchange action from whatever function changes Field A, or have that
function call Field A's onchange handler. Either way, you have to
modify the 'code that changes Field A'.

A clumsy alternative is to monitor the value of Field A (say using
setInterval at 100ms), and when it changes, fire the onchange
handler. But what if the value is being changed by the user and they
are only half way through changing it? You'll have to wait for the
control to change *and* lose focus. But if the user modifies it then
clicks 'submit', the monitoring function may not run between the
control losing focus and the submit event occurring, so you also need
to fire the onchange onsubmit - but (probably) not if it's already
been run. So now you need to remember if you've run the function
since the last change and blur events...

Hence it is a clumsy and impractical idea - it just keeps getting more
complex and hence less reliable.
--
Rob

Apr 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.