N
N
NiktarioN2019-05-04 15:55:58
PHP
NiktarioN, 2019-05-04 15:55:58

How to send page title and url in feedback form?

How to send a feedback form with the data from the form, also the title of the form and the url of the page from which it was sent

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vitaliy Orlov, 2019-05-04
@NiktarioN

you can add any hidden fields to the form using the html input tag with the hidden type

<input type="hidden" name="url" value="тут-url-страницы">
<input type="hidden" name="form-title" value="тут-название-формы">

the fields themselves can either be filled in advance through php, or catch the event of the "on submit" form through js and fill them before submitting the form

D
Dmitry Davydov, 2020-09-23
@dimadv7

Create a hidden field on a form

<input class="some-class" type="hidden" name="url">

Next, in the script file we write:
// jQuery
$(function ($) {
 $('.some-class').val(window.location.href);
});

or
// js
document.addEventListener("DOMContentLoaded", () => { 
 let urlInput = document.querySelector('.some-class');
 urlInput.value = window.location.href;
});

Don't forget to wrap it in a script tag if you add it to html.

A
aelkov, 2022-01-21
@aelkov

Figured it out:
$(function ($) {
$('.set-url').val(window.location.href);
$('.set-tit').val(window.document.title);
});
THANK!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question