Copy codeThe Code is as follows:
<Script type = "text/javascript">
$ (Document). ready (function ()
{
$ ('. Edit_link'). click (function ()
{
$ ('. Text_wrapper'). hide ();
Var data={('.text_wrapper'{.html ();
$ ('. Edit'). show ();
Certificate ('.editbox').html (data );
$ ('. Editbox'). focus ();
});
$ (". Editbox"). mouseup (function ()
{
Return false
});
$ (". Editbox"). change (function ()
{
$ ('. Edit'). hide ();
Var boxval = $ (". editbox"). val ();
Var dataString = 'data = '+ boxval;
$. Ajax ({
Type: "POST ",
Url: "update_profile_ajax.php ",
Data: dataString,
Cache: false,
Success: function (html)
{
Parameters ('.text_wrapper'{.html (boxval );
$ ('. Text_wrapper'). show ();
}
});
});
$ (Document). mouseup (function ()
{
$ ('. Edit'). hide ();
$ ('. Text_wrapper'). show ();
});
});
</Script>
<Style type = "text/css">
Body
{
Font-family: Arial, Helvetica, sans-serif;
Font-size: 12px;
}
. Mainbox
{
Width: 250px;
Margin: 50px;
}
. Text_wrapper
{
Border: solid 1px # 0099CC;
Padding: 5px;
Width: 187px;
}
. Edit_link
{
Float: right
}
. Editbox
{
Overflow: hidden; height: 61px; border: solid 1px # 0099CC; width: pixel PX; font-size: 12px; font-family: Arial, Helvetica, sans-serif; padding: 5px
}
</Style>
<Div class = "mainbox">
<A href = "#" class = "edit_link" title = "Edit"> Edit </a>
<? Php
Include ("db. php ");
$ SQL = mysql_query ("select email from users where user_id = '1 '");
$ Row = mysql_fetch_array ($ SQL );
$ Profile = $ row ['email '];
?>
<Div class = "text_wrapper" style = ""> <? Php echo $ profile;?> </Div>
<Div class = "edit" style = "display: none "> <textarea class =" editbox "cols =" 23 "rows =" 3 "name =" profile_box "> </textarea> </div>
</Div>
Update_profile_ajax.php
Copy codeThe Code is as follows:
<? Php
If ($ _ POST ['data'])
{
$ Data = $ _ POST ['data'];
$ Data = mysql_escape_String ($ data );
$ SQL = "update users set email = '$ data' where user_id = '1 '";
Mysql_query ($ SQL );
}
?>