Question : Stopping Ajax / PHP form from automatically incrementing form id tag

I have a form that I am trying to troubk=le shoot.  Whenever the value is submitted it is always the first record's value,  So I copied the output to my html editor and found that it's incrementing the values of the form id's!  

I have a simple SQL statement that creates a loop to list all the tasks and creates a form within each loop.  The output looks something like this:

<form><input type="hidden" id="taskid" name="taskid" value="15"></form>
<form><input type="hidden" id="taskid0" name="taskid" value="16"></form>
<form><input type="hidden" id="taskid1" name="taskid" value="17"></form>
<form><input type="hidden" id="taskid2" name="taskid" value="18"></form>
<form><input type="hidden" id="taskid3" name="taskid" value="19"></form>
<form><input type="hidden" id="taskid4" name="taskid" value="20"></form>

It's dynamic so I am not putting the extra number after the ID name!  How do I stop this?

The ajax is getting the value:
var taskid = encodeURI(document.getElementById('taskid').value);

I tried using document.getElementsByName since the name field doesn't increment but it doesn't seem to do anything.  

Answer : Stopping Ajax / PHP form from automatically incrementing form id tag

You could try using the jquery library and do something like this..
include jquery library in the html head

$(document).ready(function(){

$('input [type=hidden]').each(function(){   //captures and package all hidden elements
  value = $(this).value;    ///this  will get the value for each of the hidden elements  one at a time
    ///put ajax call here..  each hidden  element value will be processed one at a time ...loop
   });
});
Random Solutions  
 
programming4us programming4us