Solved

Creating a search field that will search our website and produce results

Posted on 2014-01-13
11
231 Views
Last Modified: 2014-01-22
I have created a search field for our website and when I test it, it just goes back to the home page.  Here is the code:

<form action="http://www.companysite.com" method="post" class="search-form">
    	<label for="search">Search</label>
    	<input type="search" placeholder="Search" title="Search" class="q" name="search" id="search">
    	<input type="submit" class="submit" value="Go" name="submit">
</form>

Open in new window


What am I doing wrong?

Thanks,
John
0
Comment
Question by:jebolton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39778210
Either you need to use some type of server side code that will search your database or an index OR you are using https://developers.google.com/custom-search/ or I keep forgetting about bing http://www.bing.com/blogs/site_blogs/b/developer/archive/2010/03/22/add-a-bing-search-box-to-your-site-in-3-easy-steps.aspx
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39780264
it's going back to the homepage because your action attribute in your form tag is set to your home page. how exactly are ypu producing the results?
0
 

Author Comment

by:jebolton
ID: 39780816
I got it through a tutorial.  I'm thinking I need a cgi script or a javascript to fix this problem.

I looked into the google and bing custom search and I'm wondering if there is a free (ad free) script out there that would do the job.  My deadline prevents me from learning the code and creating my own version at this point.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39780942
If you don't mind going to another tab to google there is always

 <form action="https://google.com/search" method="get" target="_blank">
    Search me<br>
    <input name="q"><br>
    <button type="submit">Search</button>
    
  </form>

Open in new window


Or use serverside code to direct to

https://www.google.com/search?q=site:yourdomaine.com+search_term
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39780951
post the link to the tutorial and maybe we can figure out how it works
0
 

Author Comment

by:jebolton
ID: 39781058
Scott,
  So would I put the "server side" code mentioned above after the action statement in parentheses?
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39781115
>So would I put the "server side" code mentioned above after the action statement in parentheses?

I meant use php/asp and process but you could just use javascript.

http://jsbin.com/aquWEDa/2/edit

<!DOCTYPE html>
<html>
<head>

<meta charset=utf-8 />
 
<script>
function searchMe(){
	var myTextField = document.getElementById('myText');
	if(myTextField.value != "")
		window.open("https://www.google.com/search?q=site:yourdomaine.com+" + myTextField.value)
	else
		alert("Please enter a search term")		
}
</script>
<title>JS Bin</title>
</head>
<body>
<input type='text' id='myText' />
<input type='button' onclick='searchMe()' value='Search' />

</body>
</html>

Open in new window

0
 

Author Comment

by:jebolton
ID: 39786777
I have decided to go the Google custom search route.  I have it working on the site but I need to customize it to fit the are I want to put it.
0
 

Author Comment

by:jebolton
ID: 39799945
What I ended up doing was to purchase the Google site search.  Working with the support specialist and the ability to remove ads, it was well worth the purchase.  The search feature is up and running in the design and format that I wanted.  Thanks for the insights and suggestions.
0
 

Author Closing Comment

by:jebolton
ID: 39799953
Thanks for your help Scott.
0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39799967
I think that was the best choice to use custom search! and pay!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question