Search code examples
phpwordpressactionsearch-form

Add suffix to action url


I have this form

<form role="search" method="get" id="searchform" class="searchform" action="http://search.site.com/Archive/search/read" >

<div>
    <input type="text" value="" placeholder="text" name="query" id="?" />
    <input type="submit" id="searchsubmit" value="." />
</div>
</form>

I need to add this suffix at the end of the url: &title=&start_year=&end_year=

For example:

http://search.site.com/Archive/search/read?query=pertini&title=&start_year=&end_year=

Where the query is: pertini

Is it possible in JavaScript or jQuery or in PHP?

Site only support GET method.

I am working in WordPress.


Solution

  • Just add hidden fields for all the ones you need:

    <form role="search" method="get" id="searchform" class="searchform" action="http://search.site.com/Archive/search/read">
        <div>
            <input type="text" value="" placeholder="text" name="query" id="?" /><input type="submit" id="searchsubmit" value="." />
        </div>
        <input name="title" type="hidden" value="" />
        <input name="start_year" type="hidden" value="" />
        <input name="end_year" type="hidden" value="" />
    </form>