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

xmlHttpRequest and onblur

31
I'm trying to put together a form and so far it's been working fine to fill the city and state with the onblur tag once a zipcode is entered.

Tag: <input type="text" size="30" maxlength="5" name="zip" value="" id="zip" onBlur="updateCityState();">

So far when the zipcode is entered and the onblur tag fills the city and the state (from the database), I also want to show a specific telephone number and hours of service somewhere near the Title of the page. Sort of: "For Service call this number 800-XXX_XXXX M-F from 7am to 5pm"

I've tried with: <input type="text" name="service" id="service" />
I'm getting a text input box with the correct info, I just want a plain text message without the text-box around the message.

Any help or suggestions that might point me in the right direction will be appreciated :)
Jul 16 '07 #1
3 1726
iam_clint
1,208 Expert 1GB
well we need to see the function updateCityState
Jul 16 '07 #2
gits
5,390 Expert Mod 4TB
hi ...

you are welcome at TSDN ... and now to your question:

i think you have the response already ... and instead of using a input-node simply use a div and set its innerHTML-property with it ... that should do the job ;)

kind regards
Jul 16 '07 #3
edwire
31
Hi Clint here is the code for updateCityState:
[PHP]<?php
/**
* Connects to the database.
* Return false if connection failed.
* Be sure to change the $database_name. $database_username , and
* $database_password values to reflect your database settings.
*/
function db_connect() {
$database_name = 'xxxxx'; // Set this to your Database Name
$database_username = 'xxxx'; // Set this to your MySQL username
$database_password = 'xxxxx'; // Set this to your MySQL password
$result = mysql_pconnect('localhost',$database_username, $database_password);
if (!$result) return false;
if (!mysql_select_db($database_name)) return false;
return $result;
}
$conn = db_connect(); // Connect to database
if ($conn) {
$zipcode = $_GET['param']; // The parameter passed to us
$query = "select * from zipcodes where zipcode = '$zipcode'";
$result = mysql_query($query,$conn);
$count = mysql_num_rows($result);
if ($count > 0) {
$city = mysql_result($result,0,'city');
$state = mysql_result($result,0,'state');
$areacode = mysql_result($result,0,'areacode');
}
}
if (isset($city) && isset($state) && isset($areacode)) {
$return_value = $city . "," . $state . "," . $areacode;
}
else {
$return_value = "not correct".",".$_GET['param']; // Include Zip for debugging purposes
}
echo $return_value; // This will become the response value for the XMLHttpRequest object
?>
[/PHP]
Could you please show me the div code? and what to input inside the div code?

Thanks a lot!
Jul 17 '07 #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...
6
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT...
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...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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,...
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,...

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.