Answer the question
In order to leave comments, you need to log in
Is it real at all?
I am new to js.
I need to substitute the value from the input in the action of the form, I try like this:
<form action="/search/node/document.getElementById('search').value" method="get">
<span class="icon"><i class="fa fa-search"></i></span>
<input type="search" id="search" placeholder="Поиск..." />
<input type="submit">
</form>
Answer the question
In order to leave comments, you need to log in
more correctly like this:
jQuery(document).ready(function($){
$('#searchform [type="submit"]').on('click', function(e){
e.preventDefault();
$(this).closest('form').attr('action', '/search/node/' + $('#search').val()).submit();
});
});
<form>
And don't forget to add id="searchform"
to the form ( ), otherwise the code will work when submitting any form on the site. <script>...</script>
.
$('button[name=fake-submit]').on('click', function(){
$(this).closest('form').attr('action', '/search/node/' + $('#search').val()).submit();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question