473,725 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2079
"William Cole" <wr****@gmail.c omwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.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.c omwrote:
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
2598
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 print to the browser which includes some data displayed and edittable in <FORM> elements. There are a couple areas where I display a message or a calculated total to the user based on the initial values of some data elements. I would like to...
2
12158
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 , suppose we put the same value in the text box then no event is fired. If we put some other value then it became fired... It wouldn't fire if we put the same value... I don't want to use onBlur etc... Isthere any solution with onChange Event...?
1
11307
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 afterwards by onBlur. I believe this to be the case because in my onChange script, if the validation fails, I force focus back to the field element. However, the focus still falls to the next field and not back to the field I tried to force the...
5
14548
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 (style, size, etc.) the original code of the input tag is: <input type="file" onchange="alert('original')" size="30" id="filea" name="filea">
4
4081
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 dependant on data collected in the code behind on the server. I have set AutoPostback to false for the controls and added lines such as cboMyCombo1.Attributes.Add("onchange", "MyCombos_OnChange('1')"); in the Page_Load event, which is rendered OK...
5
6501
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 type=text .....>. In the onChange event a coldfusion attribute is called (like, onChange="#attributes.onChange#"). Now in the cold fusion page the 2 textboxes are defined using the single Custom tag with different name (say m and x). On the onChange...
3
4152
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 to zero. it messes up the some computation when the value is blank so i need to change this to zero. what is did was to add an onchange event handler in the text field. this calls the validate function which does the requirement of changing to...
7
2241
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 changed, do a calculation with the value of fieldx and change fieldy. Can that be done without having to add an OnCHange() event to fieldx? If so, can you give a quick example or link?
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9179
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9116
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.