From Text to Node

I have created a method that assists in creating your HTML elements in Javascript. textToNode takes a string of text and converts it into a DOM element which you may then use for insertion. It's much easier to use than creating each node seperately, adding attributes to it, then appending it to the parent. It also works for table elements (tr, td, etc.) and the option element in a drop-down box. This was created for DOMClass objects but has been very nice for creating elements on the fly. It is as easy to use as the innerHTML property of an element, but it works with table elements etc. and...read more

setProperties

One of the simple and very useful pieces of code in Pherret (a PHP 5 framework) is the setProperties() function in the base Object class. The name originally came from Java Beans and works in a similar manner. I'm sharing it because it could be used in any code with PHP 5 or PHP 4. First, here is the problem being solved. Do you ever find yourself setting and object (or array, or variables) from a HTTP post in the following manner? $user = new User(); $user->firstName = $_POST['firstName']; $user->lastName = $_POST['lastName']; $user->address = $_POST['address']; $user->city...read more

Class for the DOM

It's alive!! I have created a very cool, very simple, function to create new javascript objects that are (not just act upon) HTML DOM elements. Let me explain. Say I have a cool new tree menu I'm creating (true story), and I want others to be able to just start creating the menu items and adding them in via javascript if they need to. The ideal way would be to just say myItem = new MenuItem('Cool Item'); and have it return to me the actual menu item (the TR tag or LI tag) which can be inserted into the menu. No more of this element wrapper stuff. I don't want to code my classes to act upon a...read more

Creating Objects (4 of 5)

This is the fourth of five articles on object oriented-programming. An Introduction to Object-Oriented Programming Thinking Object-Oriented Planning an Application Creating Objects Making Objects Reusable In the previous three object oriented programming articles written for jacwright.com, we introduced object oriented programming, spoke of thinking about a system object oriented, and discussed the importance of planning, even if only in one's head. The next two articles, Creating Objects and Reusing Objects, delve into the meatier subject of writing objects. We will be discussing how to implement...read more

Coming Soon

I have been working on a project recently which has had a shorter than comfotable deadline (working long hours, weekends, etc.). For this reason I haven't had time to upkeep the site as I would like. The information on Pherret is outdated, and there is not a good (recent) download of the framework. However, for better or for worse, the deadlines are coming this week and the following. Because of this there will not be any article this week. I hope to be able to get back on top of things at the end of this week or the end of next week. I should be able to update the information, perhaps even...read more

Very Suprised

I recently watched an email discussion comparing object-oriented programming and procedural programming in PHP. I was very surprised to see how many people there are that don’t understand the benefits of object-oriented programming and feel procedural is usually the best tool for the job. Why Object-Oriented Programming? The discussion began with a question, “why [do] folks like OOP so much in PHP?” Few of responses attempted to answer the question but most seemed to agree that perhaps OOP is over-rated and used in too many circumstances. I would like to answer that question for anyone...read more
Page 16 of 17« First...101314151617