I have an html table inside a form.
This table is filled with information from my database.
This is how the table looks like:
<table>
<tr>
<td >Number</td>
<td >Name</td>
<td >Last Name</td>
</tr>
<tr>
<td> <input type="hidden" id="number" value="1">1</td>
<td> <input type="hidden" id="name" value="John">John</td>
<td> <input type="hidden" id="last" value="Snow">Snow</td>
</tr>
<tr>
<td> <input type="hidden" id="number" value="2">2</td>
<td> <input type="hidden" id="name" value="Jean">Jean</td>
<td> <input type="hidden" id="last" value="Dow">Dow</td>
</tr>
.
.
</table>
The number of rows the table has depends on the number of rows the database throws.
If the information is correct the user will hit the form’s submit button.
The submit button will take it to a function in a js file. From there, I need to get the values of the table and send them to a php file.
To achieve that, inside the function, in the js file I’m doing:
var sNumber = $("# number ").val();
var sName = $("#name").val();
var sLast = $("#last").val();
params = '';
params += '&number='+sNumber;
params += '&name='+sName;
params += '&last='+sLast;
theUrl = 'controller.php';
$.ajax ({
url: theUrl,
data: params,
async:false,
success: function (data, textStatus)
{
}
});
But as the ids of the rows in the table are identical I’m only getting the first row’s information.
Can anyone please help me to send all the information the table has to the php file?
Many thanks
use class and do as :