title: Javascript loop to compare values in textboxes
body: <p>for starters, I'm NOT working with arrays</p>
  
  <p>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.</p>
  
  <p>The created textbox (input element) is so that the user can type in the sequential number of how to reorder the records...example</p>
  
  <p>Original Order of Records</p>
  
  <p>1 Alpha
  2 Bravo
  3 Charlie
  4 Delta
  5 Echo</p>
  
  <p>and user needs it to be in this order</p>
  
  <p>User input sequential</p>
  
  <p>2 Alpha
  5 Bravo
  1 Charlie
  4 Delta
  3 Echo</p>
  
  <p>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:</p>
  
  <p>New Order of Records</p>
  
  <p>1 Charlie
  2 Aplha
  3 Echo
  4 Delta
  5 Bravo</p>
  
  <p>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)</p>
  
  <p>I already have this:</p>
  
  <pre><code>&lt;script&gt;
  function check(){
      const t='texto';
      //var conta=1;
      var contar=&lt;?php echo $contar; ?&gt;;
      //while (conta&lt;=contar)
      for(var conta=1;conta&lt;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&gt;contar){alert('End');return;}
      }
  };
  &lt;/script&gt;
  </code></pre>
  
  <p>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....</p>
  
  <p>I'm open to suggestions in Ajax as well, but I must confess I'm a novice in that language...</p>
  
  <p>Any help or orientation will be gladly accepted, thanks in advance :)</p>