Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Updated 27-Feb-13 3:06am
v2
Comments
loctrice 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.
Phionix11 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>

<body>
</body>
</html>

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900