i am using the following AJAX request method. Most of you probably use this script allready as it seems to be everywhere online. I use it often with out issue... until now.
What I'm finding is that if the click used to initiate the onblur() used like - <input type="text" id="qty" name="qty" value="" onblur="makeRequest('ajax_insert.php?field_name=qty&field_value=',this.value);">
is on either a link or from submit button, the onblur() never gets called. In my code, the onblur() has to work if the user goes strait for the submit button before clicking anywhere else.
Any ideas on how to get it to call onblur() and refresh in a one click process? Thanks much for the help.
My AJAX code -
function makeRequest(url, parameters) {
-
-
http_request = false;
-
-
if (window.ActiveXObject) { // IE
-
-
try {
-
-
http_request = new ActiveXObject("Msxml2.XMLHTTP");
-
-
} catch (e) {
-
-
try {
-
-
http_request = new ActiveXObject("Microsoft.XMLHTTP");
-
-
} catch (e) {}
-
-
}
-
-
} else if (window.XMLHttpRequest) { // Mozilla, Safari, Sometimes IE7...
-
-
http_request = new XMLHttpRequest();
-
-
if (http_request.overrideMimeType) {
-
-
// set type accordingly to anticipated content type
-
http_request.overrideMimeType('text/xml');
-
// http_request.overrideMimeType('text/html');
-
-
}else{ alert('Did not create *http_request.overrideMimeType*'); return false; }
-
-
}
-
-
if (!http_request) {
-
-
alert('Cannot create XMLHTTP instance');
-
return false;
-
-
}
-
-
http_request.onreadystatechange = alertContents;
-
-
// FOR POST VARS
-
//http_request.open('POST', url, true);
-
//http_request.send(parameters);
-
-
// FOR GET VARS
-
//alert(url + parameters);
-
http_request.open('GET', url + parameters, true);
-
http_request.send(null);
-
-
}
-
-
function alertContents() {
-
if (http_request.readyState == 4) {
-
if (http_request.status == 200) {
-
//alert(http_request.responseText);
-
result = http_request.responseText;
-
document.getElementById('myspan').innerHTML = result;
-
} else {
-
alert('There was a problem with the request.');
-
}
-
}
-
}
-
3 1334 acoder 16,027
Recognized Expert Moderator MVP
Why not validate when the submit button is clicked that no changes have been made?
Why not validate when the submit button is clicked that no changes have been made?
hmmm... can you give an example? My form has three text fields.
acoder 16,027
Recognized Expert Moderator MVP
Your issue was with the submit button being clicked without clicking anywhere else.
Call the function that you'd call onblur onclick or even onsubmit instead.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Barry Svee |
last post by:
I'm struggling with the JavaScript blur event. I have an activex
control that I need to interact with when a window loses focus, namely
to instruct it to give up control of a barcode scanner so that the
application being brought foreward can take control.
It has been my observation that when I set the window.onblur function,
the window will gain focus and then immediately lose focus (blur) to
the first field, button, or whatever that is...
|
by: Tzachi |
last post by:
Hello all,
I have a function that dynamically adds rows and columns to the page.
Everything works well except onfocus // onblur attributes. For some
reason, when entering the input box it doesn't highlight. If I delete
the onblur line, each of the boxes is highlighted all the time
regardless of focusing the input box.
Can someone help me?
|
by: D. Alvarado |
last post by:
Hi, I'm having some trouble with the "onBlur" event in the BODY tag.
Ideally, what I want to happen is that when someone leaves window A,
window A executes a command. I had put
<body onBlur="savePage();">
I have a couple of problems. On IE 6 (win2000), whenever I put the
cursor focus on a textfield within window A, the "savePage" function
is invoked. And on Mozilla Filefox 0.9.1, the event never launches
even when I leave the...
|
by: Robert Oschler |
last post by:
I have a textarea element that I have created an onblur() handler for.
In the onblur() handler, I check to make sure that they have saved the
contents of the edit box, before leaving it.
If they have not saved the contents, when they exit the edit box, I put up
an alert telling them to perform the save.
My handler (note: the editBox variable was properly assigned a reference to
the desired HTML textarea element earlier):
|
by: neil S via DotNetMonster.com |
last post by:
I have a custom control with a textbox and dropdown list. The dropdown
list is hidden and acts as a data source for the textbox. When the user
enters text in the textbox, an onKeyup event is fired and retrieves the
first value from the dropdown list equal to that entered, and fills the
text box. Essentially, the two together are acting as a type
ahead/autocomplete thingy. All this works fine. Here's my problem: I
wanted to expose the...
| |
by: John Kotuby |
last post by:
Hello all...
I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen
to use popup windows in some cases because it makes the user experience
better (according to all the users I have polled who will be using this
app).
In an attempt to keep the popup from disappearing behind the calling window,
I am adding the onblur="FocusMe():" event to the Body tag of the popup. I
really want onblur to react to any click outside...
|
by: AmyHanson |
last post by:
I am new to mobile development and am having some trouble sources for the tasks I need to perform.
I have been looking around and I can find plenty of information on copying the file initiating on the PC end, I need it to initiate on the Mobile Device end. I need the handheld to be the device that is initiating the file copy as it is the only one that knows the name of the file(s) to be copied. I have found numerous references to using RAPI...
|
by: Duncan |
last post by:
Hi all,
I'm tearing my hair out on this!
I have a simple ASP.NET 2 page with a TextBox control, in the
PreRender I set ClientSide events:-
Response.Attributes.Add("onchange",
"javascript:alert('Changed');");
Response.Attributes.Add("onfocus",
|
by: rubenhan |
last post by:
Hey, guys.
My basic idea is this. When I write "1" in the pre-existing text field and onblur, I want to add a new field with a set of attributes, which turned out to be the same as the pre existing text field. (I don't want to use clonenode because of the compatibility issue)
So I want that new text field to behave like the old text field. However, the new text field does not create another text field when I write "1" into it and onblur...
|
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |