Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Paul Murphy
6,162 PointsGoogle customer search
Hi,
I am trying to implement a google custom search into my site. I opted against using the suggested code string that google provided as I was having difficulty styling it. So I used this instead:
<form class="group" id="searchbox_007920249510402107771:vklelu7qtb0" action="results.html">
<input value="007920249510402107771:vklelu7qtb0" name="cx" type="hidden"/>
<input value="FORID:11" name="cof" type="hidden"/>
<input type="text" name="s" style="width:220px;"id="s" value="search..." onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
<input value="Go" name="sa" type="submit"/>
Problem is that it doesn't pull up any results. How can I get this to be functional?
2 Answers
J MAC
7,944 PointsNot sure if you have figured this out yet... and hoping I'm of some help here.
Two things I see missing, off the top of my head, are the method "get" or "post" in the form and the form is not closed.
One other thing that might be missing... If your results.html. page is on your site on the same level as the page is sending from, cool. If the results.html page is somewhere else, you need to make certain to put the complete URL
html <form class="group" id="searchbox_007920249510402107771:vklelu7qtb0" action="http://www.google.com/results.html" method="get">
<input value="007920249510402107771:vklelu7qtb0" name="cx" type="hidden"/>
<input value="FORID:11" name="cof" type="hidden"/>
<input type="text" name="s" style="width:220px;"id="s" value="search..." onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
<input value="Go" name="sa" type="submit"/>
</form>
Paul Murphy
6,162 PointsJann McCaul have any ideas on the above?
J MAC
7,944 PointsHi, Paul. In answer to your question on your results page needing some code. Yes, you would need some code on the results page and something to do with the information, i.e. store it into a database, into a file, email it, etc.. and/or display it. That's where code like php, cgi, asp, etc will come into play. essentially, your results.html will need a way to "accept" the method (GET or POST) along with the values sent, then do something with them.
Hoping that helps.
Paul Murphy
6,162 PointsPaul Murphy
6,162 PointsHi, no I haven't figured it out yet. The results.html is on the same level. Do I need to have some code on results.html to fetch the search results? Will this work offline or will this only work once I have the website live?
Thanks for your help!