The Most Active and Friendliest
Affiliate Marketing Community Online!

“Propeller”/  Direct Affiliate

Google Custom Search Engine Tool

ms4u

New Member
affiliate
Hi,

I just create a new google custom search engine into my website homepage. The basic google code is as follows:

HTML:
<form action="http://www.mysite.com/search.php" id="cse-search-box">
              <div align="center">
                <input type="hidden" name="cx" value="partner-pub-xxxx" />
                <input type="hidden" name="cof" value="FORID:11" />
                <input type="hidden" name="ie" value="ISO-8859-1" />
                <input type="text" name="q" size="31" />
                <input type="submit" name="sa" value="Search" />
              </div>
            </form>
My question is, I want to create a text link with the following tracking URL with "Good Food" as search query in my home page:

HTML:
<a href="http://www.mysite.com/search.php?q=good food">Good Food</a>
How do I make the text link when each time people click the link "Good Food" at my home page, and it will direct to my search result page "search.php" with google search result displayed on page WITHOUT the need to click submit button again?

Is it possible to do it in google custom search engine? :unsure: Am I make sense?
 
dunno, depends what framework you use(js). for example, under mootools this is quite easy:

HTML:
<body>
<head>
    <title>Common searhes</title>
    <script type="text/javascript" src="http://dci.uk.net/gallery/mootools-1.2-core.js"></script>
    <script type="text/javascript" src="http://dci.uk.net/gallery/mootools-1.2-more.js"></script>
</head>
<body>
<form action="/search.php" id="cse-search-box">
    <div align="left">
        <input type="hidden" name="cx" value="partner-pub-xxxx" />
        <input type="hidden" name="cof" value="FORID:11" />
        <input type="hidden" name="ie" value="ISO-8859-1" />
        <input type="text" name="q" id="q" size="31" />
        <input type="submit" name="sa" value="Search" />
    </div>
</form>


<a class="tag_cloud" href="/search.php?q=good food">Good Food</a> |
<a class="tag_cloud" href="/search.php?q=not-so-good-food">Not-so-good Food</a> | 
<a class="tag_cloud" href="/search.php?q=microwave food">Microwave Food</a> 

<script type="text/javascript">
window.addEvent("domready", function() {
    // find all links that are with css class search_preset
    $$(".search_preset").addEvent("click", function(e) {
        
        var e = new Event(e).stop();
        
        // set the value... notice the name="q" id="q" bit.
        $("q").set("value", this.get("text").toLowerCase());
        
        // submit the form
        $("cse-search-box").submit();
        
    });
        
});
</script>
</body>
</html>

you can see it in action here: Common searhes

sorry, i am under 10 posts so can even post a doctype

obviously - if you do not want to use a framework, you can also circumvent the click and do it via plain js, probably something more like:
HTML:
<a id="search_preset" href="/search.php?q=good food">Good Food</a>...
<script>
document.getElementById("search_preset").setAttribute("href", "#")
document.getElementById("search_preset").setAttribute("onclick", "google(this);");
    
var google = function(what) {
    document.getElementById("q").setAttribute("value", what.innerHTML);
    document.getElementById("cse-search-box").submit();
    return false;
}
</script>
 
Last edited by a moderator:
MI
Back