change value of an variable input field in jquerry

questionsCategory: Questionschange value of an variable input field in jquerry
admin Staff asked 2 years ago

i want to change the value of my input field with jquery. The problem is, that the input field has a variable and i don’t know how describe this in jquery.
Without the variable all the code works, but this doesn’t help because i use the form different times on my page.

function doSth(click) {
  var value = ($(click).val());
  var name_ekt = $('[name="name[]"]').map(function() {
    return $(this).val();
  }).get();
  var dat = $("#dat").val();


  $.ajax({
    type: "post",
    url: "get_test.php",
    data: {
      name: name,
      dat: dat,
      value: value
    },
    cache: false,
    success: function(value) {
      $("#output").html(value);
    }
  });

  event.preventDefault();
}
<!DOCTYPE html>
<html>

<head>

  <link rel="stylesheet" type="text/css" href="../css/style.css">
  <script src="../js/jquery-3.2.1.js"></script>
  <script src="../js/jquery-ui.js"></script>

  <title>Modul </title>



</head>

<body>
  <br>
  <input type="text" id="dat" value="2017-06-30">
  <br>
  <br>

  <div>
    <?php for ($i = 1; $i <= 6; $i++) { ?>
    <form>
      <?php for ($x=0; $x<2; $x++) { ?>
      <input type='text' name='name[]' id="name[]"><br>
      <?php } ?>
      <button type='submit' id='save' value='<?php echo $i; ?>' onclick="doSth(this);">save</button>
      <br><br>

    </form>
    <?php } ?>
  </div>
  <div id='output'></div>
</body>

</html>