Introduction
This article will discuss how to get the value of multiple inputs inside a table. It will cover the different methods of retrieving the values, such as using JavaScript, jQuery, and HTML. It will also discuss the advantages and disadvantages of each method. Finally, it will provide some examples of how to use each method to get the value of multiple inputs inside a table.
Solution
You can use the jQuery .each() method to loop through each input element inside the table and get its value.
Example:
$(‘table tr td input’).each(function(){
var inputValue = $(this).val();
console.log(inputValue);
});
You could loop throw each td in rows.
Here is an example
$('table').find('tr').each(funtion(){
var trResult="";
$(this).find('td').each(function()
{
IF(trResult.indexOf($(this).val()) ===-1)
trResult += $(this).val() +';';
});
});
This is writen in my mobile so sorry for bad formating
3
Getting the value of multiple inputs inside a table can be a tricky task. Depending on the structure of the table, there are a few different ways to go about it. One way is to use jQuery to loop through each row of the table and get the value of the input fields. This can be done by using the .each()
method to iterate through each row and then using the .find()
method to get the value of the input fields.
For example, if you have a table with the following structure:
<table>
<tr>
<td><input type="text" name="field1" value="value1" /></td>
<td><input type="text" name="field2" value="value2" /></td>
</tr>
<tr>
<td><input type="text" name="field3" value="value3" /></td>
<td><input type="text" name="field4" value="value4" /></td>
</tr>
</table>
You can use the following jQuery code to get the value of each input field:
$('table tr').each(function() {
var field1 = $(this).find('input[name="field1"]').val();
var field2 = $(this).find('input[name="field2"]').val();
var field3 = $(this).find('input[name="field3"]').val();
var field4 = $(this).find('input[name="field4"]').val();
});
This will loop through each row of the table and get the value of the input fields. You can then use the values as needed.