change value of an variable input field in jquerry

questionsCategory: Questionschange value of an variable input field in jquerry
admin Staff asked 3 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();
  var dat = $("#dat").val();

    type: "post",
    url: "get_test.php",
    data: {
      name: name,
      dat: dat,
      value: value
    cache: false,
    success: function(value) {

<!DOCTYPE html>


  <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>


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

    <?php for ($i = 1; $i <= 6; $i++) { ?>
      <?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>

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

Share this:

Copy and paste this code into your website.