Part of a site admin - I’ve got a table of items. The user can drap table rows to reorder the items and update the database. Also, ever other row is stripped. This much is working properly. What I’m having trouble with - the first cell of each row displays the sort number ($allTABS[‘cal_order’]). I simply can NOT get these to update without refreshing the entire page.
Suggestions please?
The Jquery:
[code]$(document).ready(function(){
/* sortable */
$(’#calTABLE tbody’).sortable({
helper: fixHelper,
update:function(event,ui) {
var sortOrder = $(this).sortable(‘toArray’).toString();
$.post(‘qry/jq_order_tabs.php’,{sortOrder:sortOrder});
$('#calTABLE tbody tr').removeClass('alt');
$('#calTABLE tbody tr:odd').addClass('alt');
var counter = 1;
$('#calTABLE tbody tr').each(function(){
$(this).find('.sorter').val(counter);
counter=counter+1;
});
}
});
// color the table
$('#calTABLE tbody tr').mouseover(function() {$(this).addClass('over');});
$('#calTABLE tbody tr').mouseout(function() {$(this).removeClass('over');});
$('#calTABLE tbody tr:odd').addClass('alt');
});[/code]
The display php/html :
[php]
<?php echo $allTABS['cal_order']; ?> | Delete <?php echo $allTABS['calendar_title']; ?> |
The update query:
[php]$action = mysql_real_escape_string($_POST[‘action’]);
$updateRecordsArray = $_POST[‘recordsArray’];
if ($action == “updateRecordsListings”){
$listingCounter = 1;
foreach ($updateRecordsArray as $recordIDValue) {
$query = "UPDATE cal_calendars
SET cal_order = " . $listingCounter . "
WHERE calendar = " . $recordIDValue;
mysql_query($query) or die('Error, insert query failed');
$listingCounter = $listingCounter + 1;
}
}[/php]