PhpRiot
Download This Article
Download this article in PDF format with all listings and files.

Price: $5.00 AUD
(Approx. $4.10 USD)

More information
Related Books
The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP

The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP

With over 3 million users worldwide, Adobe's Dreamweaver is the most popular web development...

The Essential Guide to Dreamweaver CS4 with CSS, Ajax, and PHP (The Essential Guide)

The Essential Guide to Dreamweaver CS4 with CSS, Ajax, and PHP (The Essential Guide)

Dreamweaver CS4 is a massive step forward in terms of integration with the rest of the CS4 suite...
Browse Articles
Ajax (4), APC (1), CAPTCHA (1), CSS (3), Debugging (1), File Upload (1), Google (3), Google Maps (2), JavaScript (12), JSON (2), MVC (1), MySQL (7), onbeforeunload (1), OOP (1), PHP (28), PhpDoc (1), PostgreSQL (6), Prototype (11), Reflection (1), RFC 1867 (1), Robots (1), Scriptaculous (1), SEO (1), Sessions (1), SimpleXML (1), Smarty (5), SOAP (1), SPL (1), Templates (2), W3C (1), XHTML (1), Zend Framework (1), Zend_Search_Lucene (1)

PhpRiot Newsletter
Your Email Address:

Cloning Google Suggest With Ajaxac

Creating The Html Search Interface

The first thing we need to do is create the HTML for the seach form. This really just consists of a form, with a text input box and a submit button. We’re also going to create the DIV that will serve as our dropdown box to hold the dynamically fetched search results.

After this we will style the page.

This code goes into index.php.

Listing 1 listing-1.html
<html>
    <head>
        <title>phpRiot Tutorial: GoogleSuggestClone</title>
        <link rel="StyleSheet" type="text/css" href="googlesuggestclone.css" />
    </head>
    <body>
        <form method="get" id="f">
            <input type="text" name="q" id="fq" />
            <input type="submit" value="Search" id="fs" />
            <div id="search-results">
                <div class="sr">
                    <span class="srt">google</span>
                    <span class="src">155,000,000 results</span>
                </div>
                <div class="srs">
                    <span class="srt">google.com</span>
                    <span class="src">1 result</span>
                </div>
            </div>
        </form>
    </body>
</html>

We give each of the elements an ID, as we will need to reference them later — ‘f’ is for form, ‘fq’ for form query, and ‘fs’ for form submit.

Also, we created two sample search results that we can use for styling. The DIV to hold these results is search-results, a non-selected item is class sr (“search result”), and a selected item is class srs (“search result selected”).

We will alter this later to remove those sample search terms.

In This Article


Tagged in , , ,