I have very little JavaScript knowledge, I'm picking up a project where someone left off at...they used the draggable function to rearrange the table in a database. The issue is, the data is being duplicated in the database table on submit.
function submit(){
var orderID = [];
var partID = [];
var amtID = [];
var carTypID = [];
var cmpndID = [];
var prodAmt = [];
var prodDte = [];
var seq = [];
var perd = [];
var strDate = document.getElementById('strDate').value;
var currentUser = document.getElementById('currentUser').value;
var mach = document.getElementById('passMach').value;
$("td.index").each(function() { orderID.push($(this).text()) });
$("td.partID").each(function() { partID.push($(this).text()) });
$("td.amtID").each(function() { amtID.push($(this).text()) });
$("td.prodAmt").each(function() { prodAmt.push($(this).text()) });
$("td.carTypID").each(function() { carTypID.push($(this).text()) });
$("td.cmpndID").each(function() { cmpndID.push($(this).text()) });
$("td.prodDte").each(function() { prodDte.push($(this).text()) });
$("td.seq").each(function() { seq.push($(this).text()) });
$("td.perd").each(function() { perd.push($(this).text()) });
var count = orderID.length;
var redirect = "";
for(var i = 1; i <= count; i++){
//document.getElementById('index'+i).value = orderID[i-1];
//document.getElementById('part'+i).value = partID[i-1];
//document.getElementById('amt'+i).value = amtID[i-1];
//document.getElementById('carTyp'+i).value = carTypID[i-1];
//document.getElementById('cmpnd'+i).value = cmpndID[i-1];
redirect = redirect + "index"+i+"="+orderID[i-1]+"&";
redirect = redirect + "part"+i+"="+partID[i-1]+"&";
redirect = redirect + "amt"+i+"="+amtID[i-1]+"&";
redirect = redirect + "prod"+i+"="+prodAmt[i-1]+"&";
redirect = redirect + "carTyp"+i+"="+carTypID[i-1]+"&";
redirect = redirect + "cmpnd"+i+"="+cmpndID[i-1]+"&";
redirect = redirect + "prodDte"+i+"="+prodDte[i-1]+"&";
redirect = redirect + "seq"+i+"="+seq[i-1]+"&";
redirect = redirect + "perd"+i+"="+perd[i-1]+"&";
}
redirect = redirect + "mach="+mach+"&";
redirect = redirect + "machAdd="+mach+"&";
redirect = redirect + "currentUser="+currentUser+"&";
redirect = redirect + "strDate="+strDate+"&";
redirect = redirect + "rows="+count;
redirect = ":updateTreadSchedule.jsp?"+redirect;
window.location = redirect;
//alert(orderID.join('\n'));
//alert(partID.join('\n'));
//alert(amtID.join('\n'));
//alert(carTypID.join('\n'));
//alert(cmpndID.join('\n'));
}
$(document).ready(function() {
var fixHelperModified = function(e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function(index) {
$(this).width($originals.eq(index).width())
});
return $helper;
},
updateIndex = function(e, ui) {
$('td.index', ui.item.parent()).each(function (i) {
$(this).html(i + 1);
});
};
$("#sort tbody").sortable({
helper: fixHelperModified,
stop: updateIndex
}).disableSelection();
});
Thanks for any help.