for starters, I'm NOT working with arrays
with that being said, I need your help...I created a webform in PHP that retrieves values from a mysql table and displays them with its own mysqli_fetch_array command, in that loop it generates a textbox for each record...so far so good.
The created textbox (input element) is so that the user can type in the sequential number of how to reorder the records...example
Original Order of Records
1 Alpha 2 Bravo 3 Charlie 4 Delta 5 Echo
and user needs it to be in this order
User input sequential
2 Alpha 5 Bravo 1 Charlie 4 Delta 3 Echo
the new order of the records will be saved on a temporary table in the database before insertion on the main table, kinnda like a preview for the new order, something like this:
New Order of Records
1 Charlie 2 Aplha 3 Echo 4 Delta 5 Bravo
Now what I need is a function that helps me display a message if the user duplicates a sequential unique, if they type in number 1 in 2 or more records, when I hit the button for the preview I need it to loop through all the input boxes and check their values, compare it with the other inputs and determine if there are duplicates or not....if there're no duplicates, continue with PHP code.....if there are duplicates, display an error so the user seeks for the duplicate and change it (inputs left in blank will not be considered for the insertion in the preview table)
I already have this:
<script>
function check(){
const t='texto';
//var conta=1;
var contar=<?php echo $contar; ?>;
//while (conta<=contar)
for(var conta=1;conta<contar;conta++)
{
alert(conta);
var contas=conta+1;
if (document.forms['OrderPreview'][t+conta].value!=document.forms['OrderPreview'][t+contas].value)
{
alert('All Good');
return false;
}
else
{
alert('Something bad');
return true;
}
//conta++;
contas=conta+1;
if (contas>contar){alert('End');return;}
}
};
</script>
Which only works with first and second inputs....currently I have 62, but this number is random for every data upload...I was reading some posts here stating that using autoincrements in javascript is bad but as you can see I've tried both ways of doing the autoincrement and none seems to work properly....
I'm open to suggestions in Ajax as well, but I must confess I'm a novice in that language...
Any help or orientation will be gladly accepted, thanks in advance :)