Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gary Hockin  >  "Clevertext" AJAX text box  >  readme.txt  >  Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: Readme file
Class: "Clevertext" AJAX text box
Generate editable text box that is saved with AJAX
Author: By
Last change: Added some security warnings.
Date: 2006-07-11 06:48
Size: 1,987 bytes
 

Contents

Class file image Download
** "Clevertext" AJAX Textbox Readme File **
** Gary Hockin - gary --at-- garyhockin --dot-- co --dot-- uk **
** June 2006 **

Intro
This class generates a "Clevertext" textbox that contains data from a database, and can be edited on the fly. Basically, the class generates a div tag containing the unetidable text, and a hidden textbox containing the editable text. When you double click on the div, the javascript hides the non-editable div, and displays the text field. When you then click out of the textbox, AJAX is used to update the database with the new contents of the textbox, update the contents of the non-editable div, and then display the div and hide the textbox. It all sounds rather confusing but if you look at the example it should be obvious enough!

Usage

Include the class.clevertext.php file using the normal method:

include('clevertext/class.clevertext.php');

Create a new instance of the clevertext class:

$ct = new clevertext;

Then, initialise the class using the init method, passing the path:

$ct->init('clevertext');

Next, create a clevertext textbox by using the textbox function:

$ct->textbox(fieldname, fieldvalue, table name, primary key, primary key value);

Thats it!

You'll need to edit clevertext.php to connect to your database or to include your globals, but essentially thats all there is to it.

Obviously this is a hugely simplified version as the original used the PEAR db_data_objects classes to handle the database calls, and did some data validation (hence the "error" part of the xml generated). Want some more info? EMail me at the above address.

*EDIT*
Please note this is cleaned down to the barest form to get people to understand how it works. There is NO input validation at all included. I HIGHLY RECOMMEND that you add at least a htmlentities value in the "clevertext.php".
*DOUBLE EDIT*
I have added the htmlentities in myself just in case stupid people do stupid things with the class.