Uppercase First letters with javascript

If you have a string in javascript and you want to the first letter to be uppercase / a capital then this line of code will do that for you:

str = str.slice(0,1).toUpperCase() + str.slice(1);

If you want to convert more than one letter then you might want to use the following. As examples if you wanted the first 4 characters uppercase use (0,3) and then (4) and if you wanted the first 2 uppercase you would use (0,1) and then (2)

str = str.slice(0,3).toUpperCase + str.slice(4);

Remember that an array starts at zero so always take one from the numbers you want.

PHP coding standards I agree with

In all my time coding php I have read a lot of php coding standards.

Finally I have found one that I almost agree with completely. My only wobble is regarding the suggestion not to use getters and setters in classes.

PHP Coding standards

The PHP Coding Standard is with permission based on Todd Hoff‘s C++ Coding Standard.
Rewritten for PHP by Fredrik Kristiansen / DB Medialab, Oslo 2000-2003.

jCrop – jQuery’s Image Cropper

I have been doing a lot of javascript coding recently. It’s funny because until six months ago I was a javascript beginner. I had done some js but didn’t completely get it and began by copying and pasting from other sites in the hope that things would just work. Then again that’s how I started with php too.

As I began to work on PagePlay more and more the javascript needed to be more and more clean and easy to adapt for when we add new functionality.

Continue reading “jCrop – jQuery’s Image Cropper”