A lot. You need to put the PHP code in a separate file. To use Ajax, you need to use the XMLHttpRequest object, not location.href. Get a simple Ajax page working first and then extend to your particular problem.
							
						
					Populate second text box based on value extracted from first text box
				
					Collapse
				
			
		
	X
- 
	
	
	
		
	
	
	
		
	
		
			
				
	
	
	
	
	
	
	
	
	
 and the php code isCode:function test1() { var a=document.getElementById("first").innerHTML; var b=a.split('/'); var c=b[0]; var d=b[1]; if(c!="snow") { document.getElementById("second").innerHTML=""; return; } xmlHttp=GetXmlHttpObject(); if(xmlHttp==null) { alert("your browser does not support ajax"); return; } var url="cd.php"; url=url+"?d="+d; url=url+"&sid="+math.random(); xmlHttp.onreadystatechange=StateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function StateChanged() { if (xmlHttp.readyState==4) { document.getElementById("second").innerHTML=xmlHttp.responseText; } } </script> <body> <input type="text" id="first" size="40" onKeyUp="test1();"/><br><br> <input type="text" id="second" size="40"/> </body> </html>
 
 [PHP]<?php
 $fog=$_GET['d'];
 echo $fog;
 ?>
 [/PHP]
 What is wrong with this code am not able to print anything in the second text box.
 Can somebody reply to it fast plz...Comment
- 
	
	
	
		
	
	
	
		
	
		
			
				
	
	
	
	
	
	
	
	
	
 php code isCode:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <script type="text/javascript"> function test1() { var a=document.getElementById("first").value; var b=a.split('/'); var c=b[0]; var d=b[1]; if(c!="fog") { document.getElementById("second").value=""; return; } xmlHttp=GetXmlHttpObject(); if(xmlHttp==null) { alert("your browser does not support ajax"); return; } var url="cd.php"; url=url+"?d="+d; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=StateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function StateChanged() { if (xmlHttp.readyState==4) { document.getElementById("second").value=xmlHttp.responseText; } } </script> </head> <body> <input type="text" id="first" size="40" onkeyup="test1();"/><br><br> <input type="text" id="second" size="40"/> </body> </html>
 Code:<?php $fog=$_GET['d']; echo $fog; ?> Comment
- 
	
	
	
		
	
	
	
		
	
		
			
				
	
	
	
	
	
	
	
	
	
 Please enclose your posted code in [code] tags (See How to Ask a Question).
 
 This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
 
 Please use [code] tags in future. Thanks.
 
 Moderator.Comment
Comment