add hidden inputs in form

This commit is contained in:
2024-06-17 11:30:05 +03:00
parent d7584deff0
commit b4abd8eec6
6 changed files with 74 additions and 21 deletions

25
partials/formhash.php Executable file
View File

@@ -0,0 +1,25 @@
<?$addrhash = adddr_hash();
if ($addrhash !== null):?>
<script>
document.addEventListener('DOMContentLoaded', function() {
let form = document.getElementById('form-right');
let inputAdded = false;
form.addEventListener('mouseenter', function() {
if (!inputAdded) {
var hiddenInput = document.createElement("input");
hiddenInput.type = "hidden";
hiddenInput.name = "addrhash"; // имя поля
hiddenInput.value = "<?=$addrhash?>"; // значение поля
form.appendChild(hiddenInput);
inputAdded = true;
}
}, { once: true });
});
</script>
<?endif;?>