473,416 Members | 1,503 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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

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
2 2040
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dan baker | last post by:
I am pretty much a newbie with javascript, and would like to get a little clarification on what I can do with an onChange javascript event handler. I have a dynamic page I build with perl and...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
1
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time...
5
by: Good Man | last post by:
Hi there I'm adding form fields on the fly with some javascript DOM programming. I basically just clone a hidden <div>, then adjust node properties to make this new <div> have unique values...
4
by: Zeebra3 | last post by:
Here goes: I have a web form with several asp:dropdownlists, with which, when selection is changed I want to fire an event defined in some clientside js. The content of the clientside code is...
5
by: subhodey | last post by:
Hello, I have a ColdFusion online application that has a page having 2 textboxes. Corresponding to these 2 textboxes I have a Custom tag in coldfusion where the textbox is defined by <input...
3
by: lowslyn | last post by:
hi, can someone please help me with javascript... i have this code that checks a text field when the user overrides the value to blank/space. if it is blank/space, i need to change the value...
7
by: TriAdmin | last post by:
I am working with a system that allow me to add custom fields but I can not add OnChange() language to the custom fields. So I want to have a function in the header that recognizes when fieldx is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.