I have a form like this
<form method="get" id="searchform" action="http://domain.com">
<input name="s" id="s" type="text" />
<input type="submit" id="searchsubmit" type="submit" />
</form>
When I add some keyword on search input text, The URL is going as http://domain.com/?s=keyword
I need it as http://domain.com/?s=keyword&post_type=events
Means I need just &post_type=event added on url. How can I do it? any suggestion?
Add a hidden field
<input type="hidden" name="post_type" value="events">
Please try this code...
<form method="get" id="searchform" action="http://domain.com">
<input name="s" id="s" type="text" />
<input type="submit" id="searchsubmit" name="post_type" value='event'/>
</form>
When you press button it return to like.
http://domain.com/?s=keyword&post_type=events
Related
I currently built a simple form to GET request someones zipcode.
<form action="http://example.com" method="get" target="_blank">
<p>ZIPCODE</p>
<input type="text" name="zip">
<input type="submit" value="Submit">
</form>
When submitted it will be http://example.com/?zip=ZIPCODE
What I am looking to do it add an additional piece so it will be http://example.com/?zip=234&country=usa
I tried adding a hidden field <input type="hidden" name="country=usa"></input> but this replaces = with %3D and adds = after it like so: http://example.com/?zip=ZIPCODE&country%3Dusa=
How can I easily append the URL with country=usa?
Try:
<form action="http://example.com" method="get" target="_blank">
<p>ZIPCODE</p>
<input type="text" name="zip">
<input type="hidden" name="country" value="usa">
<input type="submit" value="Submit">
</form>
In this page : page.php?id=value
I've this html's code:
<form action="" method="get">
<input type="text" name="key" />
<input type="submit" name="send />
</form>
It's redirect me to: page.php?key=value , i want to redirect to: page.php?id=value&key=value , how i can do it? I must redirect it to this page with PHP ?
simply,
<form action="page.php" method="get">
<input type="hidden" name="id" value="<?php echo $value ?>">
<input type="text" name="key" />
<input type="submit" name="send" />
</form>
You can have the id as a hidden input in your form
<form action="" method="get">
<input type="hidden" value="<?php echo $my_id; /*Suppose this variable contain your value */ ?>" name="id" />
<input type="text" name="key" />
<input type="submit" name="send" />
</form>
put everything you want on the next page in your form:
<form action="page.php" method="get">
<input type="text" name="id" value="<?php echo $_REQUEST['id'];?>" />
<input type="text" name="key" />
<input type="submit" name="send />
</form>
Really though, you should be using POST to send data, and the above code is NOT secure (allows anything in a url to easily end up in a form that could create some sql injection or XSS type issues.
You need to have the form's action set to the page you want it to submit to. If it is blank it will just submit to the same page.
<form action="page.php?id=value&key=value" method="get">
<input type="text" name="key" />
<input type="submit" name="send />
</form>
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.
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>
I'm using mod_rewrite to mask the address. Like 'contact' instead 'index.php?page=contact. I have a problem with the internal search engine on the page.
Form of search engine:
<form id="search" action="search" method="GET">
<input type="text" placeholder="Search" name = "co" id="s" />
<input type="submit" />
</form>
The result is:
domainname.com/search?co=word
How receive this word? $ _GET ['co'] doesnt work. Just does not work:
<form id="search" action="index.php?page=search" method="GET">
If you write your html withouth spaces
<form id="search" action="search" method="GET">
<input type="text" placeholder="Search" name="co" id="s" />
<input type="submit" />
</form>
everything should work if you use $_GET['co']
I have a form for searching products which will be visible in each page. When the search button is clicked it will redirect to a search.php page. I want to send a query string (parameter) with the content of the search text box when the button is clicked. The code for the form is simple, but here it is:
<form method="post" action="search.php">
<input type="text" id="txtSearch" name="txtSearch" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" ?>'" />
</form>
I want that when clicked this will redirect to search.php?q=txtSearch. Thanks.
Change "POST" to "GET" on the form element and change the input name parameter to "q".
use :
<form method="get" action="search.php">
<input type="text" id="txtSearch" name="q" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" />
</form>
<form method="post" action="search.php?q=txtSearch">
<input type="text" id="txtSearch" name="txtSearch" class="searchInput" value="" />
<input type="submit" id="btnSubmit" name="btnSubmit" value="Search" />
</form>
This way submitting the form you'll be redirect to search.php?q=txtSearch and from php you can get the $_POST variable so
$_POST['txtSearch']
$_POST['btnSubmit']
Just use GET instead of POST
<form method="get" action="search.php">
The name of the fields will be the name of the querystring variable. Like this:
?input_name=input_value