HTML
  Home arrow HTML arrow Page 4 - Sending Email with AJAX: Building a Small ...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Sending Email with AJAX: Building a Small Application
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 26
    2006-01-17

    Table of Contents:
  • Sending Email with AJAX: Building a Small Application
  • Getting started: developing the application’s user interface
  • Spicing things up: writing the CSS rules for the AJAX email application
  • Working with building blocks: defining the (X)HTML markup for the email application

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Sending Email with AJAX: Building a Small Application - Working with building blocks: defining the (X)HTML markup for the email application


    (Page 4 of 4 )

    Since I’ve already defined the CSS styles responsible for achieving the visual appearance of the user interface that integrates the application, the only remaining step that I need to complete this project is to write the (X)HTML markup for the corresponding web page, so both document structure and visual presentation are hooked up to each other. Having said that, here is the underlying markup, which completes the required pieces for rendering the user interface. Take a look:

    <div id="container">
    <div id="contsection">
    <h1>CONTACT LIST</h1>
    <form>
    <input name="add" type="button" value="Add Contact" class="mailbutton" title="Add new contact" />
    </form>
    </div>
    <div id="mailsection">
    <h1>STATUS: COMPOSING NEW MESSAGE</h1>
    <form>
    <input name="subject" type="text" value="SUBJECT: "
    class="mailfield" title="Enter message's subject" />
    <input name="to" type="text" value="TO: " class="mailfield"
    title="Enter recipient's email address" />
    <input name="cc" type="text" value="CC: " class="mailfield"
    title="Enter email address for carbon copy" />
    <input name="bcc" type="text" value="BCC: " class="mailfield"
    title="Enter email address for blind carbon copy" />
    <textarea name="message" title="Type your message
    here" /></textarea>
    <input name="send" type="button" value="Send Message"
    class="mailbutton" title="Send Message" />
    <input name="clear" type="reset" value="Clear Message"
    class="mailbutton" title="Clear Message" />
    <input name="contact" type="button" value="Display Contacts"
    class="mailbutton" title="Display Contact List" />
    </form>
    </div>
    </div>

    As you’ll probably agree, the above (X)HTML markup is fairly simple, but worth spending a few minutes examining in detail, since all the further behaviors –- added by the inclusion of JavaScript code -- will be implemented on this web page structure.

    As illustrated above, the markup is comprised of the three containing DIVS that I mentioned previously, named “container”, “contsection” and “mailsection” respectively. Additionally, the right-positioned DIV wraps up the appropriate form (handy for sending out email messages) and the set of control buttons, which are responsible for performing the tasks I described before. Now, coming to the left-placed DIV, you can see that it only houses a <h1> header and the “Add Contact” labeled button, which probably makes you wonder: where’s the list of contacts I saw in the previous screenshot? Right, there’s still no contact list because it will be added dynamically via JavaScript and the DOM, so don’t worry about this issue for the moment.

    Now that you know what the (X)HTML markup of the email application looks like, let’s take a final step and put it together with the CSS styles that you saw earlier, so you can have a clear idea of how the complete presentational layer is implemented. Here’s the full source code for the user interface, which will be used by the AJAX-driven email program:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>AJAX-DRIVEN MAIL CLIENT</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-
    8859-1">
    <style type="text/css">
    body {
                margin: 0;
                padding: 0;
    }
    h1 {
                font: bold 16px Arial, Helvetica, sans-serif;
                margin: 5px;
    }
    a:link,a:visited {
                display: block;
                width: 120px;
                padding: 2px 0 2px 5px;
                font: bold 12px Verdana, Arial, Helvetica, sans-
    serif;
                color: #00f;
                text-decoration: none;
                border: 1px solid #cc3;
    }
    a:hover {
                color: #f33;
                background: #fff;
                border: 1px solid #000;
    }
    form {
                display: inline;
    }
    textarea {
                width: 575px;
                height: 380px;
                margin-left: 5px;
                background: #ffc;
                border: 1px solid #000;
    }
    #container {
                width: 800px;
                height: 572px;
                padding: 5px;
                margin-left: auto;
                margin-right: auto;
                background: #cc9;
                border: 1px solid #000;
    }
    #mailsection{
                float: left;
                width: 590px;
                height: 570px;
                margin-left: 5px;
                background: #cc3;
                border: 1px solid #000;
    }
    #contsection {
                float: left;
                width: 200px;
                height: 570px;
                background: #cc3;
                border: 1px solid #000;
                overflow: auto;
    }
    .mailfield {
                width: 575px;
                height: 20px;
                margin: 0 0 5px 5px;
                border: 1px solid #000;
                background: #ffc;
                font: bold 11px Verdana, Arial, Helvetica, sans-
    serif;
                color: #000;
    }
    .mailbutton {
                width: 120px;
                height: 25px;
                margin-left: 5px;
                font: bold 11px Verdana, Arial, Helvetica, sans-
    serif;
                color: #000;
    }
    .contfield {
                width: 185px;
                height: 20px;
                margin: 0 0px 5px 5px;
                border: 1px solid #000;
                background: #ffc;
                font: bold 11px Verdana, Arial, Helvetica, sans-
    serif;
                color: #000;
    }
    </style>
    </head>
    <body>
    <div id="container">
    <div id="contsection">
    <h1>CONTACT LIST</h1>
    <form>
    <input name="add" type="button" value="Add Contact"
    class="mailbutton" title="Add new contact" />
    </form>
    </div>
    <div id="mailsection">
    <h1>STATUS: COMPOSING NEW MESSAGE</h1>
    <form>
    <input name="subject" type="text" value="SUBJECT: "
    class="mailfield" title="Enter message's subject" />
    <input name="to" type="text" value="TO: " class="mailfield"
    title="Enter recipient's email address" />
    <input name="cc" type="text" value="CC: " class="mailfield"
    title="Enter email address for carbon copy" />
    <input name="bcc" type="text" value="BCC: " class="mailfield"
    title="Enter email address for blind carbon copy" />
    <textarea name="message" title="Type your message
    here" /></textarea>
    <input name="send" type="button" value="Send Message"
    class="mailbutton" title="Send Message" />
    <input name="clear" type="reset" value="Clear Message"
    class="mailbutton" title="Clear Message" />
    <input name="contact" type="button" value="Display Contacts"
    class="mailbutton" title="Display Contact List" />
    </form>
    </div>
    </div>
    </body>
    </html>

    Here I’ve provided you with the complete source code that renders the user interface of the AJAX-based email application. However, if you don’t feel inclined to wait for the upcoming articles of the series, you can download the full code of the AJAX email program here or at the beginning of this article.

    Bottom line

    We’re done for the moment. However this is only a brief pause, since I’ve just outlined the guidelines for how the AJAX-based email application will work. What’s next though? In the next tutorial, I’ll be coding the corresponding behavior layer, including the full set of JavaScript functions that interact with the server-side scripts and add interactivity to each of the user controls I discussed earlier. So, don’t ever think about missing the next part!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Without a doubt, AJAX exposes a great versatility for building different Web-based...
       · The AJAX Email tutorial is very interesting and should be helpful to those who want...
       · Hello,I thank you for posting your comments on this tutorial, and of course it's...
     

    HTML ARTICLES

    - Using a 3D HTML Table as a Recordset
    - Building a 3D HTML Table
    - Maximizing and Restoring HTML Images: Layer ...
    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT