PHP Code
<table>
<Tr><Td colspan="2">如果本例看不到数据请先添加一条记录,点击<a href="?action=add">这里可以添加</a></Td></Tr>
<?php
$sql="select * from `add_delete_record` where id>0";
$rs=mysql_query($sql);
if ($row = mysql_fetch_array($rs))
{
do {
?>
<Tr bgcolor="#eeeeee">
<Td><?php echo $row['id']?></Td>
<Td class="bigclassname" ><span title="点击修改"><?php echo $row['text']?></span></Td>
</Tr>
<?php
}
while ($row = mysql_fetch_array($rs));
}?>
</table>
JavaScript Code
<script>
$(function() {
$(".bigclassname").click(function() {
var objTD = $(this);
var oldText = $.trim(objTD.text());
var input = $("<input type='text' value='" + oldText + "' />");
objTD.html(input);
input.click(function() {
return false;
});
input.css("font-size", "16px");
input.css("text-align", "center");
input.css("background-color", "#ffffff");
input.width("120px");
input.select();
input.blur(function() {
var newText = $(this).val();
objTD.html(newText);
var bigclassid = objTD.prev().text();
newText = escape(newText);
var url = "update.php? + newText;
$.get(url, function(data) {});
});
});
});
</script>