Mysql
 sql >> Datenbank >  >> RDS >> Mysql

php Foreach-Schleife und Addmore-Button in einem Formular

Verwenden Sie den folgenden Code, um das geklonte Formular zu löschen:

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
 var i = 0;
 var original = document.getElementById('duplicater');

  function duplicate(){ 
    var clone = original.cloneNode(true); // "deep" clone
    i = ++i;
    clone.id = "duplicetor"+ i; // there can only be one element with  an ID
    original.parentNode.appendChild(clone);
    clearCloneForm(clone.id);
  }

  function clearCloneForm(id){ 
    var divId = '#'+id;
    $(divId).find("input[type^='text'], input[type^='date']").each(function() {
        $(this).val('');
    }); 
  }
</script>