User1686398519 posted
Hi, Sepjak
According to your needs, I made an example. This example uses an ajax request to pass data to the controller and return the result.
Controller
public ActionResult TestListResult()
{
return View();
}
[HttpPost]
public ActionResult TestListResultGet(Array List1, Array List2)
{
//List<string> test1 = new List<string>{ "A", "B", "A", "C", "A" };
//List<string> test2 = new List<string> { "A", "C", "A", "B", "A" };
List<Boolean> test3= new List<Boolean>();
for(int i = 0; i < List1.Length; i++)
{
if (List1.GetValue(i).Equals(List2.GetValue(i)))
{
test3.Add(true);
}
else{
test3.Add(false);
}
}
return Json(test3,JsonRequestBehavior.AllowGet);
}
TestListResult
<button>getResult</button>
<table class="table">
<thead>
<tr>
<td>List1</td>
<td>List2</td>
<td>Result</td>
</tr>
</thead>
<tbody>
<tr><td>A</td><td>A</td><td></td></tr>
<tr><td>B</td><td>C</td><td></td></tr>
<tr><td>A</td><td>A</td><td></td></tr>
<tr><td>C</td><td>B</td><td></td></tr>
<tr><td>A</td><td>A</td><td></td></tr>
</tbody>
</table>
@section scripts{
<script>
$("button").click(function () {
var List1Array = new Array();
var List2Array = new Array();
$('table tbody tr').each(function () {
$(this).children('td:eq(0)').each(function () {
List1Array.push($(this).text());
});
$(this).children('td:eq(1)').each(function () {
List2Array.push($(this).text());
});
});
$.ajax({
url: '/Home/TestListResultGet',
dataType: 'json',
type: "POST",
data: { List1: List1Array, List2: List2Array },
success: function (data) {
$('table tbody tr').each(function () {
$(this).children('td:eq(2)').each(function (i) {
$(this).empty();
});
});
$('table tbody tr').each(function (i) {
$(this).children('td:eq(2)').each(function () {
if (data[i]) {
$(this).prepend('<span class="alert-success">' + data[i] + '</span>');
} else {
$(this).prepend('<span class="alert-danger">' + data[i] + '</span>');
}
});
});
}
});
});
</script>
}
Here is the result.

Best Regards,
YihuiSun