Answer the question
In order to leave comments, you need to log in
How to transfer data from input to URL?
Hello. I need that when the button is clicked, the text goes from the input to the URL to the place of the asterisks. Please tell me how to do it. I use flask, so maybe somehow through a template engine? Preferably without JS and Python, everything is in HTML.
<form action="/searcha?title=***" method="GET">
<label>
<input type="text" name="search_content" placeholder="Поиск">
<input type="submit" value="Найти">
</label>
</form>
Answer the question
In order to leave comments, you need to log in
Found a solution. I had to use JavaScript, but it was worth it.
HTML
<div class="search">
<label>
<input class="search_input" type="text" name="search_content" placeholder="Поиск">
<input type="button" value="Найти" onclick="search_generate_url('title')">
</label>
</div>
function search_generate_url(type) {
let search_content = document.getElementsByClassName('search_input')[0].value
let url = 'search?' + type + '=' + search_content;
location.assign(url);
}
location.assign(url);
you can use location.assign(location.href + url);
if you need the parameters (in my case title) to be added, that is, /search?title=1, then /search?title=1search?title=1, etc. You can also use it location.assign(url)
location.href = url;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question