Web Hosting Talk







View Full Version : lostfocus event


amberlong83
12-18-2009, 03:46 AM
I am building a program in which i have two text boxes... one for txt1(country) and other for txt2(city)..
I want any lostfocus() event available in html/php from which i can call my another php file,, so i fill txt2 according to txt1.

rasin
12-18-2009, 06:33 AM
try this simple example

<script>
function change(id) {
document.getElementById('txt2').value = id.value;
}
</script>
<html>
<head><title>Example</title></head>
<body>
<form name="form1" action="">
<input type="textbox" name="txt1" id="txt1" onchange="change(document.getElementById(this.id));"><br>
<input type="textbox" id="txt2" name="txt2">
</form>
</body>
</html>


if you need to call php file then you can use Ajax

hope this helps you
Rasin

mattle
12-18-2009, 10:11 AM
Check out onBlur()

http://www.htmlcodetutorial.com/document/_BODY_onFocus.html

amberlong83
12-19-2009, 03:28 AM
yeah rasin this is realy help me, thanks.