|
|
|
เรื่องการสร้างถังขยะ drag and drop การลบรูปภาพและไปลบในฐานข้อมูลด้วย |
|
|
|
|
|
|
|
Code (jQeury)
<head>
<script src="http://code.jquery.com/jquery-1.6.2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.js"></script>
<style>
.selected {
background-color:gray !important;
}
</style>
</head>
<?php
$aaa = array();
$aaa[] = array(1, "Data One", "Data Two");
$aaa[] = array(2, "Data Three", "Data Four");
$aaa[] = array(3, "Data Five", "Data Five");
$aaa[] = array(4, "Data AAA", "Data BBB");
$aaa[] = array(5, "Data AAAAAA", "Data SSSSBBB");
?>
<table border=1>
<tr class='record'>
<td align="left" valign="middle" bgcolor="#FFFFFF" class="rows">Row</td>
<td align="left" valign="middle" bgcolor="#FFFFFF" class="rows">Data 1</td>
<td align="left" valign="middle" bgcolor="#FFFFFF" class="rows">Data 2</td>
</tr>
<?php $i=0;
foreach($aaa as $row)
{$i++;
?>
<tr class='record'>
<td align="left" valign="middle" class="rows"><?=$row[0]?></td>
<td align="left" valign="middle" class="rows"><?=$row[1]?></td>
<td align="left" valign="middle" class="rows"><?=$row[2]?></td>
</tr>
<?php } ?>
</table>
<input type="button" id="deleterecords" value="Delete">
<script type="text/javascript">
$(document).ready(function() {
// assign attribute selected to clicked rows
$("tr[class*='record']").live('click', function() {
// comment line below if you want multi-selected records,
$("tr[class*='selected']").removeClass("selected");
$(this).addClass("selected");
});
// remove selected records upon clicking delete
$("input[id='deleterecords']").live('click', function() {
$("tr[class*='selected']").remove();
});
});
</script>
http://stackoverflow.com/questions/6936964/drag-and-delete-with-jquery-and-php
|
|
|
|
|
Date :
2012-10-04 11:24:34 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|