With ajax get hml input (array-row) then if condition true pass to php file

Multiple html input rows like this

<tr id='row1'>
<td><input type="text" name="row1[]" id="date_day1" class="row_changed1"></td>
<input type="text" name="row1[]" id="is_row_changed1" size="1">
$(".row_changed1").on("change", function () {
document.getElementById('is_row_changed1').value = 1;

At the moment for each row separate ajax code like this

if ($("#is_row_changed1").val() > 0) {
$.post("_autosave_array.php", $("#row1 :input").serialize(), function(data1) {
var str = $("#row1 :input").serialize();

if ($("#is_row_changed2").val() > 0) {
$.post("_autosave_array.php", $("#row2 :input").serialize(), function(data2) {
var str = $("#row2 :input").serialize();

Aim is to get write ajax code like foreach if ($(“#is_row_changed1,2,…1000”).val() > 0) {pass corresponding input <tr>“#row1,2,…100 :input” to php

May be some link/information/sample? To what direction to go…

You can do that by using Attribute Starts With Selector [name^=“value”]

A good way to get ready for that process is to turn some of your existing code in to a function:

function autosave(suffix) {
    if ($("#is_row_changed" + suffix).val() > 0) {
        $.post("_autosave_array.php", $("#row" + suffix + " :input").serialize(), function(data) {
            $('#load' + suffix).html(data);
            $('#is_row_changed' + suffix).val(0)
       var str = $("#row" + suffix + " :input").serialize();
       $("#load" + suffix + "_1").text(str);


Doing the above will help to ensure that your code carries on doing the same thing that it should be doing.

After making the above type of change, you can then replace those calls to the autosave function with something like this:

$('[id^="row"]').each(function (index, row) {
    var suffix = row.id.substring(3);

Thank you for advice!

Will go through code to understand

Script works without


I deleted, but the script works…

Yes, that is the point of the jQuery code that was put up afterwards. It’s to replace the functionality of the autosave commands that you removed.

ah, yes, now understand
Very useful code!
Exactly what is necessary