Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML PHP jQuery
I am new to php and jquery and I am stuck at one point in displaying result to textbox.
 
I have created 1 client.php file where i have 1 employee id textbox,submit button, employee name textbox.
Now i am using jquery to get employee id from textbox and clicks on submit button then it showed display the name of the employee whose that particular employee id is,
example:employee id: 100
here is my submit button
below that i have employee name textbox and the result should be displayed as,
Employee Name: ABC (in textbox).
 
I have created 1 server.php file where i am selecting the data from mysql database.
 
In server.php file i am getting data from mysql database and want to pass it to client.php file.
 
Data is comming from database correctly but the only problem is showing it on the textbox.
I have used google chrome debuuger to check if data is comming or not and it is coming neatly.
 
Please suggest any solution for these if any...
Posted 27-Feb-13 4:05am
Amol011691
Edited 27-Feb-13 4:06am
v2
Comments
loctrice at 27-Feb-13 10:57am
   
you should post your client side html and jquery code. If you know the data is coming from the server correctly, then that will help us trouble shoot it.
amolpatil011 at 28-Feb-13 7:09am
   
My "client.php" code is as show below,
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Get Details of Specified Employee</title>
 
<script src="http://code.jquery.com/jquery-latest.js"></script>
 
<script type="text/javascript">
function getdetails()
{
var empid=$('#txtid').val();

$.ajax( {
type: "POST",
url: "server.php",
data: { empid:empid}

} ).done(function( result ) {
//document.getElementById('txtname').innerHTML = result['empname'];
//.done(function( result ) {
$("#lblid").html( result['empname'] );
//$('#txtname').val(result["name"]);
//$('#txtsal').val(result["salary"]);
//$('<%=txtname.ClientID %>').val(result["empname"]);
//$('#txtname').val($('#txtid').val());
//$("#txtsal").val( result['empname']);
/*var gg=result['empname'];
$('#lblid').html( " Address of Roll no is "+result );
$('#txtname').val(gg);*/

//document.getElementById('txtname').value=result.content.document;
} );
 
}
</script>
 
</head>
 
<body>
<table width="577" border="1">
<tr>
<td width="142">Employee ID</td>
<td width="229"><label for="txtid"></label>
<input type="text" name="txtid" id="txtid" /></td>
<td width="184"> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="btnsubmit" id="btnsubmit" value="Submit" önclick="getdetails()" /></td>
<td> </td>
</tr>
<tr>
<td>Employee Name</td>
<td><label for="txtname"></label>
<input type="text" name="txtname" id="txtname" /></td>
<td> </td>
</tr>
<tr>
<td>Employee Salary</td>
<td><label for="txtsal"></label>
<input type="text" name="txtsal" id="txtsal" /></td>
<td> </td>
<td><label id="lblid">
</label>
</td>
</tr>

<tr>
<td><label id="lblid">
</label>
</td>
<td>
</td>
<td>
</td>
</tr>
 


 
</table>
</body>
</html>
 
And "server.php" code is ,
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
$empid=$_POST['empid'];
 
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("employee",$con);
$query="SELECT empname from emp where empid=".$empid;
 
//$result=array();
$result= mysql_query($query,$con);
 

$row=mysql_fetch_array($result);
echo $row['empname'];
 
?>
<body>
</body>
</html>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Marcin Kozub 265
1 Richard MacCutchan 239
2 OriginalGriff 208
3 Sergey Alexandrovich Kryukov 185
4 Praneet Nadkar 167
0 OriginalGriff 7,913
1 Sergey Alexandrovich Kryukov 7,232
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 19 Feb 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100