how to search the given string in google using text input field? - html

Hi I am using this form code to enter get the text field. in that text field i will enter some string for search and i press submit button.when i click on submit button it show the search results in google search engine how to do this.
<!DOCTYPE html>
<html>
<body>
<form name="input" action="index.html" method="get">
Search:<input type="text" name="user">
<input type="submit" value="Submit">
</form>
</body>
</html>
Can anyone help me? Thanks In advance......

Simply imitate how Google does it. The key items are the action attribute and the use of the name q for the string:
<!doctype html>
<meta charset=utf-8>
<title>Google search</title>
<form action="http://www.google.com/search">
<label for=q>Keyword(s):</label>
<input type=text name=q size="32" id=q>
<input type="hidden" name="ie" value="utf-8">
<input type="hidden" name="oe" value="utf-8">
<input type="submit" value="Search">
</form>

You can use the Google Custom Search API for this.

Related

fill url parameter value based on form input

I have a URL looks like this
site.com/dir/?id=xxx
is it possible to create an HTML form that allows the user to enter the value of id and opens the page in other tab?
thank you.
This is the very basic HTML code to do it :
<!DOCTYPE HTML>
<HTML>
<body>
<h1>The input element</h1>
<form action="https://www.google.com/dir/" target="_blank">
<label for="id">Enter value of ID:</label>
<input type="text" id="fname" name="id"><br><be>
<input type="submit" value="Submit">
</form>
<p>Click the "Submit" button to open page in new tab.</p>
</body>
</html>

How do I create a link to google image search via HTML 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

Send form to remote server

I want to use the service provided at http://zxing.org/w/decode.jspx with a custom form in my own site. I've written the following code:
<html>
<body>
<FORM action="http://zxing.org/w/decode.jspx" method="post">
<INPUT type="text" name="u" value="http://justinsomnia.org/images/qr-code-justinsomnia.png">
<INPUT type="submit" value="Send">
</FORM>
</body>
</html>
When I submit the form, I'd expect to see the results page with a "Decode Succeeded" message. Instead, I see the original remote form I'm trying to duplicate.
Can you spot what's wrong with my custom form?
<html>
<body>
<FORM action="http://zxing.org/w/decode" method="get">
<INPUT type="text" name="u" value="http://justinsomnia.org/images/qr-code-justinsomnia.png">
<INPUT type="submit" value="Send">
</FORM>
</body>
</html>
You should use get instead of the post method. You are posting to the wrong URL, post to http://zxing.org/w/decode. I checked it, it's working now.

Add Google search in web page

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'.

DHL Tracking HTML Form?

Does anyone know if I can create an HTML Form to search the DHL tracking website?
http://www.dhl.co.uk/en/express/tracking.html
I have tried using the following but get the error 'down for maintenance':
<!DOCTYPE html>
<!--[if IE]>
<![endif]-->
<html><head><meta charset="utf-8" />
</head>
<body>
<form action="http://www.dhl.co.uk/content/gb/en/express/tracking.shtml?brand=DHL&AWB=1212121212" method="post">
<input type="submit" value="go" />
</form>
</body>
</html>
Will I have to use the API?
The following HTML tracking sample enables you to insert a single waybill number into a tracking field and submit the request via your existing web page. This link takes you to the DHL tracking screen, automatically populating the shipment information.
<html>
<head>
<title>DHL - Track By Tracking Number</title>
</head>
<body>
<form name="form1" method="get" action="http://www.dhl-usa.com/content/us/en/express/tracking.shtml?">
< input type=hidden name=brand VALUE="DHL">
<input type="text" name="AWB" size="10"><br>
<input type="submit" value="Submit"><br>
<input type="reset" value="Reset">
</body>
</html>
Big shout out to #WeezHard for dropping that form. I figured his solution is directed at DHL USA, so if you want a global DHL tracking form you can use the follow code.
<form name="form1" method="get" action="https://www.dhl.com/global-en/home/tracking/tracking-express.html?submit=1&tracking-id=" target="_blank">
<input type=hidden name=submit VALUE="1">
<input type="text" name="tracking-id" size="10" placeholder="Enter your DHL waybill number here..."><br>
<input type="submit" value="Track">
</form>
I modified #WeezHard codes to adapt Aramex courier tracking
<form name="form1" method="get" action="https://www.aramex.com/track/results?
ShipmentNumber=" target="_blank">
<input type="text" name="ShipmentNumber" size="11" placeholder="Enter your AWB"><br>
<input type="submit" value="Track">
<input type="reset" value="Reset">
</form>
feel free to use it! ;)