Style Sheets
  Home arrow Style Sheets arrow Page 2 - Creating a Simple Date Picker with JavaScr...
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? 
STYLE SHEETS

Creating a Simple Date Picker with JavaScript and CSS
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 20
    2007-02-21

    Table of Contents:
  • Creating a Simple Date Picker with JavaScript and CSS
  • An Example Form
  • The Calendar Popup
  • The CSS

  • 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


    Creating a Simple Date Picker with JavaScript and CSS - An Example Form


    (Page 2 of 4 )

    Initially, you'll need an example form, with some date fields on it. I won't waste time by using an elaborate form, so we'll just have a couple of example fields on it that will serve to illustrate the date picker. Something like the following should suffice:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    http://www.w3.org/TR/html4/strict.dtd>
    <html lang="en">
     
    <head>
       
    <title>Date Picker Example</title>
     
    <head>
     
    <body>
       
    <h1>A Generic Form</h1>
       
    <div>
         
    <form action="">
           
    <span> Enter A Date:</span><input type="text"><img
    src="calendar.gif" alt="Datepicker">
         
    </form>
       
    </div>
     
    </body>
    </html>

    We begin with the DOCTYPE, naturally, then a basic page with a basic form on it. The lang attribute of the HTML element is included for validity. Save this as datepicker.html or something similar. Now we can add some CSS to make the page look a little more appealing and line things up better. Add the following selectors and rules to a new page in your text editor:

    h1 {
     
    font-family:arial, sans-serif;
     
    color:#003399;
     
    border-bottom-width:3px;
     
    border-bottom-color:#ffcc00;
     
    border-bottom-style:solid;
    }

    img {
     
    position:relative;
     
    top:10px;
     
    padding-left:10px;
    }

    .text {
     
    font-family:arial, sans-serif;
     
    color:#003399;
     
    padding-right:10px;
    }

    .textbox {
     
    border-width:1px;
     
    border-color:#ffcc00;
     
    border-style:solid;
    }

    You'll also need to go back to the HTML and add the code shown in bold below:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    http://www.w3.org/TR/html4/strict.dtd>
    <html lang="en">
     
    <head>
       
    <title>Date Picker Example</title>
       
    <link rel="stylesheet" type="text/css"
    herf="datepicker.css">
     
    <head>
     
    <body>
       
    <h1>A Generic Form</h1>
        
    <div>
         
    <form action="">
           
    <span class="text">Enter A Date:</span><input
    class="textbox" type="text"><img src="calendar.gif"
    alt="Datepicker">
         
    </form>
        
    </div>
      
    </body>
    </html>

    So now it should look adequate for this example.

    More Style Sheets Articles
    More By Dan Wellman


       · Hi Everyone, thanks for reading. The date picker is a useful addition to anyone...
       · The .picker style specifies display:none...so if you wonder why your calendar...
       · The display style is dynamically changed with JavaScript in the next article, which...
       · hey dear when will be the next part published
       · Hi, the next part of the tutorial has been published, it can be found at...
       · its very nice. But somehow I am unable to get the calender when click on calender...
       · Do you get any javascript errors?
       · I got some errors at first as well... you have to be very precise in assembling all...
       · Hi... I really liked this 4 part series. There is one aspect of this project which...
       · These images do contain the orange fill but they are slices 1px wide to save in...
       · hmmm... somehow all of the code I posted between the html tags didn't make it in...
       · Hi,very good job. I'd like to use your datePicker but the provided ZIP file...
       · what's your email Marion, I'll mail it to youRegardsDan
     

    STYLE SHEETS ARTICLES

    - Improving the Visual Presentation of a CSS D...
    - Fixing Browser Incompatibilities in a CSS Dr...
    - Building Clean Drop-Down Menus with CSS
    - Creating Hybrid Web Page Layouts with Negati...
    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification






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