Trevor
Trevor

Reputation: 2457

html input send information to another website

I'm trying to send a string from an input box to Google's search input to search on my website.

The only way that I can think of is Posting it to my own page which then sends it to google. Is there a way to cut out that middle page and go straight to google?

Summary: Send input box string to Google's input box and search using Google.

Current thoughts of how to do this are.

  1. Make form with input box
  2. Submit form to seperate page
  3. Seperate page then redirects you to "https://www.google.com/#q=" $_POST['string'] "site:mysite.com"

But I feel like there's a better way to do this.

Thanks

Upvotes: 0

Views: 497

Answers (1)

user3329899
user3329899

Reputation:

<input type="text" class="foo">
<button onclick="send()">Submit</button>

<script type="text/javascript">
function send(){
  var value = $('.foo').val();
  window.location.href = "https://www.google.com/#q="+value+" site:mysite.com";
}
</script>

Upvotes: 1

Related Questions