AJAX-enabled Sticky Notes With PHP & jQuery

22 January 2010 Friday

This application was viewed 1379 times




AJAX-enabled Sticky Notes With PHP & jQuery

Today we are making an AJAX-enabled Sticky Note management system. It will give visitors the ability to create notes with a live preview, and move them around on the screen. Every movement is going to be sent to the back-end via AJAX and saved in the database.

We are using version 1.4 of jQuery and the fancybox plugin (you can also check our CSS3 Lightbox Gallery Tutorial, where we also used fancybox).

You can download the example files and keep the demo site open in a tab so that it is easier to follow the steps of the tutorial.

Step 1 – XHTML

The first step is to create the necessary XHTML structure. The markup in the main demonstration file – demo.php is pretty straightforward, as you can see for yourself from the code below.

demo.php

1.<div id="main">
2.<a id="addButton" class="green-button" href="add_note.html">Add a note</a>
3.  
4.<?php echo $notes?>
5.  
6.</div>

It contains the main div, which holds all the notes and limits their movement during the dragging process. The rest is generated dynamically by PHP after running a SELECT query against the database, and after storing the result in the $notes variable as you will see in the next step.

If you click the “Add a note” button on the demonstration site, you will see that a form with a live preview pops up. This functionality is provided by the fancybox, which fetches add_note.html (which contains the form) and shows it within a pop-up.

add_note.html

01.<h3 class="popupTitle">Add a new note</h3>
02.  
03.<!-- The preview: -->
04.<div id="previewNote" class="note yellow" style="left:0;top:65px;z-index:1">
05.<div class="body"></div>
06.<div class="author"></div>
07.<span class="data"></span>
08.</div>
09.  
10.<div id="noteData"> <!-- Holds the form -->
11.<form action="" method="post" class="note-form">
12.  
13.<label for="note-body">Text of the note</label>
14.<textarea name="note-body" id="note-body" class="pr-body" cols="30" rows="6"></textarea>
15.  
16.<label for="note-name">Your name</label>
17.<input type="text" name="note-name" id="note-name" class="pr-author" value="" />
18.  
19.<label>Color</label> <!-- Clicking one of the divs changes the color of the preview -->
20.<div class="color yellow"></div>
21.<div class="color blue"></div>
22.<div class="color green"></div>
23.  
24.<!-- The green submit button: -->
25.<a id="note-submit" href="" class="green-button">Submit</a>
26.  
27.</form>
28.</div>

In the form you can fill in the text of the note, your name and choose a color. Providing a way for users to see how their note will appear in the page in real time is a useful addition which serves another practical purpose – when clicking the submit button and the lightbox window closes, the preview note is copied to the main div, which saves us from writing additional code.

View The DEMO

Tags: php, ajax, jquery,


AJAX-enabled Sticky Notes With PHP & jQueryBookmark and Share

You write your thoughts

Please login to post comments here from the right corner.

your add
icon free icon icon set vector icon free catalog catalog template jquery news ticker widget tools tutorial php slider video youtube effects menu thumbnail forms facebook zoom image combo multiselect modal polaroid gallery expand code feedback contact navigation slider tagcloud Skateboard psd templates files badges subscribe panel login temlate file free office holland free template tabs prototype css scriptaculous opacity moo autocomplete wordpress themes design theme button images photoshop fonts font nav pdf logo style high javascript pretty photo jqery lightbox Themes Blog popular blog desing joomla xhtml brushes hair footer admin mootols slide show blackbox new download class first plugin upload browse Page effect modalbox web application urlitooltips sliding boxes captions flatchat chat ajax messaging browser hoverlightbox CSS Dev General Javascript PHP SQL search avatar vector Drupal Joomla Oscommerce javaScript phototype manager ajaxplorer flash xml rotator bookmarking pageflip slideshow poll text component script mediaplayer imagegallery pictograms car poster player mp3 radio onlineradio navigations drop-down collection brush tree textures paper pop-up bumpbox web2.0 iphone film frame twitter page fan mail delete dynamic calender form handbook city social paint timeline clock connect bar sharing accordion quotes ticker photo-effects background 3D media player graphic rss leaf green glossy bubble icon comic clean cool web 2.0 png actionscript ietter rotating Menu animated textured site masking pasword app layer sponge bob popup bubble tooltips horizontal prototip tooltip pack charachters comics blog action icon.psd flavour navi tango gradients istanbul mixed css3 sleek animations program html5 website Layer styles ultimate candy Media icons dropdown snow icon innerfade hover sub tag