www.webdeveloper.com
Results 1 to 4 of 4

Thread: Creating a custom Google search...

  1. #1
    Join Date
    Dec 2012
    Posts
    81

    Creating a custom Google search...

    I have a site here. (JSFiddle here)

    I am trying to create a custom search.

    The idea is the check one radio button, and then based on the zip code entered (and keywords in the background), I want results to display.

    Example: Check "Libraries" and enter 18337. Result: All local libraries in that zip code will display.

    I've gotten most of the code written, but I'm having the hardest time with getting keywords recognized.

    Code:
    <section class="lib-search">
    <form method="get" action="http://www.google.com/search"> 
       	<table border="0" cellpadding="0"> 
           	<tr>
               	<td> 
                   	<input type="text" name="q" size="25" maxlength="50" value="" /> 
                   	<input type="submit" value="Search" />
    			</td>
    		</tr> 
                
            <tr>
               	<td align="center" style="font-size:75%">
    	            <input type="radio" name="sitesearch" value="google.com" checked /> Libraries
                    <input type="radio" name="sitesearch" value="google.com" /> Fax
                    <input type="radio" name="sitesearch" value="google.com" /> Ice Cream                    
    			</td>
    		</tr>
    	</table> 
    </form>
    </section>
    Thoughts?
    ____________________________________
    sƃoɹɟqǝʍ Design Studios
    Phoenix | Arizona

    E: webfrogs@webfro.gs

  2. #2
    Join Date
    Oct 2012
    Posts
    78
    Code:
    <section class="lib-search">
    <form method="get" action="http://www.google.com/search"> 
       	<table border="0" cellpadding="0"> 
           	<tr>
               	<td> 
                   	<input type="text" name="q" size="25" maxlength="50" value="" id="google" /> 
                   	<input type="submit" value="Search" />
    			</td>
    		</tr> 
            
                
            <tr>
               	<td align="center" style="font-size:75%">
    	            <input type="radio" name="sitesearch" value="google.com" onclick="act('Libraries')"/> Libraries
                    <input type="radio" name="sitesearch" value="google.com" onclick="act('Fax')"/> Fax
                    <input type="radio" name="sitesearch" value="google.com" onclick="act('Ice Cream')"/> Ice Cream                    
    			</td>
    		</tr>
    		<script type="text/javascript">
    					function act(change) {
    					myOption = change;
    					document.getElementById("google").value = myOption;
    					}
    		</script>
    	</table> 
    </form>
    </section>
    Requires Javascript. I wasn't sure if you want another row of options underneath with there we pre defined zip codes which the user could check.

  3. #3
    Join Date
    Dec 2012
    Posts
    81
    We are close, but what I'd really like to see happen is when "Libraries" is clicked on, it remains hidden in the input field. Then, the user simply enters their respective zip code, and on the Google results page, it would show "local library 90210" (as an example).

    Does that make sense?
    ____________________________________
    sƃoɹɟqǝʍ Design Studios
    Phoenix | Arizona

    E: webfrogs@webfro.gs

  4. #4
    Join Date
    Oct 2012
    Posts
    78
    Don't think thats possible with JavaScript. Mabye someone else might be able to help you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles