Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-13
11
Medium Priority
?
235 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
  • 5
  • 4
  • 2
11 Comments
 
LVL 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 1500 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 34

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 54

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 34

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 54

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 54

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 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