I'd like to add search to a static site. The simplest way is to simply query Google by appending "site:www.acme.com" to the actual query so that Google will limit search to that site.
Ideally, I'd like to do this in the browser, to avoid having to install PHP on the server. Using a form, I don't know how to append the search items:
<form action=http://www.google.com?q="site:www.acme.com+...">
<input type=text id=search_item>
</form>
Does someone know of a client-side solution? Should I use some JavaScript for this?
Thank you.
Edit: When using "method=get" and "input name=q value="site:www.acme.com "", the browser will indeed call Google with "www.google.com?q="site:www.acme.com some item", but I'd rather avoid presetting the input box with "site:www.acme.com" because users will find this odd and might remove it.
You just need to set the form method to "get", add one extra hidden element with the site you want to search and it will automatically paste it behind the URL as such:
<form action="https://google.com/search" method="get">
<input type="hidden" name="sitesearch" value="http://acme.com" />
<input type="text" name="q" />
</form>
Because that is how HTML forms work by default.
u can do something like this:
<script type="text/javascript">
function google_search()
{
window.location = "http://www.google.com/search?q=site:www.acme.com+" + encodeURIComponent(document.getElementById("q").value);
}
</script>
<form onSubmit="google_search()">
<input type="text" name="q" id="q" value="" />
<input type="submit" value="search" onClick="return google_search()" />
</form>
<form method="get" action="http://google.com/search">
<input type="text" name="q" required autofocus>
<input type="submit" value="Google search">
</form>
If you want to use Bing Search engine then replace 'google' with 'bing'.
Related
I am trying to mirror the google image search.
so far I know that q is the name for the actual google search (or query).
On the address it will look: www.google.com/search?q=parrot
but on the google image search also appears /search?q=parrot&tbm=ish
I looked and found out that tbm stands for "to be match" and is a filter and I guess is the filter to match the images... but I don't have a clue how to put inside my html code.
So far I have done this:
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar"
<input type="submit" value="Search" class="submit">
</form>
How do I add the tbm filter? Thanks!
You can add a hidden input field and set the value of it.
example
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar">
<input type="hidden" name="tbm" value="ish">
<input type="submit" value="Search" class="submit">
</form>
Trying to make Google Image Search Clone using HTML form where after entering text in the search field it will take you directly to Google Image search results page.
Here is the code that I am using:
<body>
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
</body>
It will take to normal google search, how do I change it to google image search result page?
You have to change the action, as such:
<form method="get" action="http://images.google.com/images">
<input type="text" name="q" />
<input type="submit" value="Google Search" />
</form>
Google image search link is of the following format
https://www.google.com/search?q=```query```&tbm=isch
Each of the parameters, q and tbm, requires an input tag but tbm does not require any user input.
'GET_parameter_name=value' for every input tag before submit button is appended by '&'.
<form action="https://www.google.com/search">
<input type="text" name="q" id="box">
<input type="hidden" name="tbm" value="isch">
<input type="submit" value="Image Search" >
</form>
Source:
https://stenevang.wordpress.com/2013/02/22/google-advanced-power-search-url-request-parameters/
https://www.xul.fr/javascript/parameters.php
As the title states, I'm trying to incorporate many searches into one search bar. More specifically, Google and Amazon. I have setup a radio option to set which site to search when one is selected.
This is the code I currently have:
<form method="get" action="http://www.google.com/search">
<div align="center" style="font-size:75%">
<input type="text" name="q" size="25" maxlength="255" value="" />
<input type="submit" value="Google or Amazon Search" /></br>
<input type="radio" name="sitesearch" value="" />The Web
<input type="radio" name="sitesearch" value="yoursite.com" checked />This Site
</div>
</form>
I have this form for Amazon, but I'm just unsure how to code it into the one search bar.
<form action="http://amazon.com/s/ref=nb_sb_noss" method="get" target="_blank">
<input type="text" id="twotabsearchtextbox" name="field-keywords">
<input type="submit" value="Search" class="nav-submit-input">
</form>
Use JavaScript to change the actual form action in page's DOM (and other parameters, if needed), depending on the user selection (use onclick event on radio to montior for change for example). Simple as that. You won't be able to do that in pure HTML without using some kind of proxy server to redirect the requests and return the results appropriately.
document.your-form.action = (google_selected) ? "http://www.google.com/search" : "http://amazon.com/s/ref=nb_sb_noss";
etc.
What I want to accomplish is logging in to a website by simply typing in the form variables in the URL.
HTML code:
<form action="httpclient.html" onsubmit="return checkSubmit();" method="post" target="_parent" name="frmHTTPClientLogin">
<input type="hidden" name="mode" value="191">
<label>Username</label>
<input border="1" style="width:150px" maxlength="60" name="username">
<label>Password</label></pre>
<input type="password" border="1" style="width:150px" autocomplete="off" name="password" maxlength="60">
This is the relevant past of the code. Now I want to login to this site http://10.100.56.55/httpclient.html just by passing values typed in the url. Firstly is it possible. If yes then what exactly do i need to type for userame :name and password being pass ?
and what encoded URL will be passed in POST method if any?
Change method="post" to method="get"
If you want to type the Querystring in for the username and password, you need to do this in the address field of your browser:
http://10.100.56.55/?username=name&password=pass
EDIT:
You need to find out where the form is going and what it's doing. For this, you need to check what the submit javascript function called 'checkSubmit()' is doing. You can do this by opening the page in your browser and doing a view source. If the javascript is external to the html file, check the js links on the page and open those up to find that function. The function might have the querystring parameters you're looking for.
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search">
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search2">
<button type="submit" class="btn btn-default" onclick="location.href='\search.php?search='+ document.getElementById('search').value+'&search2='+document.getElementById('search2').value;"> Search</button>
the issue was in the input tag <input type="hidden" name="min_price" value="200"> forward slash was missing,I have added the forward slash and it works now <input type="hidden" name="min_price" value="200"/>.
It's not possible to do that; the form would have to use the GET method.
I know that I can create a google search box on my personal homepage using something like this (very basic code)
<form method="get" action="http://www.google.com/search">
<input type="text" name="q" />
<input type="submit" value="Google Search" />
</form>
Is it possible to change this to only return results containing C#.
If I enter stringbuilder, the above code submits
http://www.google.com/search?q=stringbuilder
whereas I want is
http://www.google.com/search?q=c%23+stringbuilder
Google supports multiple q arguments. You can generate URLs like this: http://www.google.com/search?q=text1&q=text2. In your case, add a hidden input:
<input type="hidden" name="q" value="C#" />