I want to know if it is possible to refer to an dynamically created variables and if yes how?
I create on this site many forms which have p elements on the bottom is one button and if I click that button I want to transmit the variable(IdJB) which was created specific in this form. I marked the variable with a command in the code.
$(document).ready(function() {
  var Id = sessionStorage.getItem('Id');
  var status = 0;
  var nummer = 0;
  $.ajax({
    type: "POST",
    url: "http://localhost/jQuery&PHPnew/Markt.N.php",
    data: {
      status: status
    },
    success: function(data) {
      var anzahl = data;
      status = 1;
      while (anzahl > nummer) {
        nummer++;
        $.ajax({
          type: "POST",
          url: "http://localhost/jQuery&PHPnew/Markt.N.php",
          data: {
            nummer: nummer,
            status: status
          },
          success: function(data) {
            var Daten = JSON.parse(data);
            var Ausgabebereich = document.getElementById('main');
            var IdJB = Daten.id;
            window.IdJB = IdJB; //This Variable !!!!!!!!!!!!!
            var f = document.createElement("form");
            var pInhalt = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.inhalt);
            pInhalt.appendChild(Inhalt);
            f.appendChild(pInhalt);
            var pDatum = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.datum);
            pDatum.appendChild(Inhalt);
            f.appendChild(pDatum);
            var pUhrzeit = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.uhrzeit);
            pUhrzeit.appendChild(Inhalt);
            f.appendChild(pUhrzeit);
            var pGehalt = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.gehalt);
            pGehalt.appendChild(Inhalt);
            f.appendChild(pGehalt);
            var pDauer = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.dauer);
            pDauer.appendChild(Inhalt);
            f.appendChild(pDauer);
            var pAdresse = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.adresse);
            pAdresse.appendChild(Inhalt);
            f.appendChild(pAdresse);
            var pNam_ersteller = document.createElement('p');
            var Inhalt = document.createTextNode(Daten.nam_ersteller);
            pNam_ersteller.appendChild(Inhalt);
            f.appendChild(pNam_ersteller);
            var bInhalt = document.createElement('button');
            var Inhalt = document.createTextNode("Senden");
            bInhalt.appendChild(Inhalt);
            bInhalt.setAttribute("type", "button");
            bInhalt.setAttribute("onclick", "zuJB()");
            f.appendChild(bInhalt);
            Ausgabebereich.appendChild(f);
            $(document).on('click', 'button', function() {
              sessionStorage.setItem('IdJB', IdJB); //Here !!!!!!!!!!!!!
              alert(IdJB);
              window.location = "http://localhost/jQuery&PHPnew/JobBlock.html";
            });
          }
        })
      }
    }
  })
  $("#sub").click(function() {
    window.location = "http://localhost/jQuery&PHPnew/Markt.html";
  })
})<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Jobs</title>
  <script type="text/javascript" src="jQuery.js"></script>
  <script type="text/javascript">
  </script>
</head>
<body>
  <button id="sub">Update</button>
  <a href="Markt.html">Alle Jobs</a>
  <a href="AAAngebote.html">Meine Jobs</a>
  <a href="Einstellungen.html">Einstellungen</a>
  <main id="main">
  </main>
</body>
</html> 
     
     
    