473,657 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onblur failing / not initiating

162 New Member
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
Expand|Select|Wrap|Line Numbers
  1. <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
Expand|Select|Wrap|Line Numbers
  1. function makeRequest(url, parameters) { 
  2.  
  3.     http_request = false;
  4.  
  5.     if (window.ActiveXObject) { // IE
  6.  
  7.         try {
  8.  
  9.             http_request = new ActiveXObject("Msxml2.XMLHTTP");
  10.  
  11.         } catch (e) {
  12.  
  13.             try {
  14.  
  15.                 http_request = new ActiveXObject("Microsoft.XMLHTTP");
  16.  
  17.             } catch (e) {}
  18.  
  19.         }
  20.  
  21.     } else if (window.XMLHttpRequest) { // Mozilla, Safari, Sometimes IE7...
  22.  
  23.         http_request = new XMLHttpRequest();
  24.  
  25.         if (http_request.overrideMimeType) {
  26.  
  27.             // set type accordingly to anticipated content type
  28.             http_request.overrideMimeType('text/xml');
  29.             // http_request.overrideMimeType('text/html');
  30.  
  31.         }else{ alert('Did not create *http_request.overrideMimeType*'); return false; }
  32.  
  33.     } 
  34.  
  35.     if (!http_request) {
  36.  
  37.         alert('Cannot create XMLHTTP instance');
  38.         return false;
  39.  
  40.     }
  41.  
  42.     http_request.onreadystatechange = alertContents;
  43.  
  44.     // FOR POST VARS
  45.     //http_request.open('POST', url, true);
  46.     //http_request.send(parameters);
  47.  
  48.     // FOR GET VARS
  49.     //alert(url + parameters);
  50.     http_request.open('GET', url + parameters, true);
  51.     http_request.send(null);
  52.  
  53. }
  54.  
  55. function alertContents() {
  56.     if (http_request.readyState == 4) {
  57.      if (http_request.status == 200) {
  58.         //alert(http_request.responseText);
  59.         result = http_request.responseText;
  60.         document.getElementById('myspan').innerHTML = result;
  61.      } else {
  62.         alert('There was a problem with the request.');
  63.      }
  64.     }
  65. }
  66.  
Apr 4 '08 #1
3 1334
acoder
16,027 Recognized Expert Moderator MVP
Why not validate when the submit button is clicked that no changes have been made?
Apr 5 '08 #2
empiresolutions
162 New Member
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.
Apr 7 '08 #3
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.
Apr 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
16580
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...
1
10485
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?
2
3711
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...
3
8918
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):
1
5670
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...
10
2447
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...
0
2498
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...
1
2600
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",
4
6930
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...
0
8403
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...
0
8316
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,...
0
8833
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, 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...
0
8610
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
7345
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
4168
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
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
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
1967
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.