473,385 Members | 1,356 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,385 software developers and data experts.

onblur failing / not initiating

162 100+
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 1319
acoder
16,027 Expert Mod 8TB
Why not validate when the submit button is clicked that no changes have been made?
Apr 5 '08 #2
empiresolutions
162 100+
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 Expert Mod 8TB
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
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...
1
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...
2
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...
3
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...
1
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...
10
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...
0
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...
1
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",...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.