1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
'use strict';
document.addEventListener("DOMContentLoaded", function() {
const forms = {
init() {
const original = document.querySelector('#forms form'),
button = document.getElementById('button');
button.addEventListener('click', this._add, false);
original.addEventListener('submit', this._send, false);
},
_add() {
const original = document.querySelector('#forms form');
const form = original.cloneNode(true);
original.parentNode.appendChild(form);
form.reset();
form.addEventListener('submit', this._send, false);
},
_send(e) {
e.preventDefault();
const xhr = new XMLHttpRequest();
xhr.open('POST', './generate/create.php', true);
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
console.log(xhr.status);
}
};
xhr.send(new FormData(e.target));
}
};
forms.init();
});
</script>
<style>
* { font-family: monospace; }
#button { margin: 2px 50px 20px 20px; }
.wpsl-input { list-style-type: none; }
.wpsl-input li { display: inline; }
</style>
</head>
<body>
<button id="button" onlick="duplicate()">ADD</button>
<div class="copycat" id="forms">
<form autocomplete="off" action="" method="post">
<ul class="wpsl-input">
<li>
<label>Type <input type="text" name="type" size="15" /></label>
</li>
<li>
<label>Country <input type="text" name="country" size="15" required></label>
</li>
<li>
<label>Shop <input type="text" name="shops_to_include" size="15"></label>
</li>
<li>
<label>Critere <input type="text" name="to_exclude" size="15"></label>
</li>
<li>
<label>Name File <input type="text" name="name_file" size="15"></label>
</li>
<li>
<label>Name Repository <input type="text" name="name_repertory" size="15"></label>
</li>
<li>
<label>Export Link <input type="text" name="export_link" size="15"></label>
</li>
</ul>
<input name="submit" type="submit" value="Generate">
</form>
</div>
</body></html> |
Partager