deadlock Message Board
[ February Full List | Post A Reply ]

Re: Title Case Function
From Michael Hatch on 13 Feb '02
replying to Re: Title Case Function posted by DAle

Dale,

I finally figured it out, it works something like this:

function titleCase()
{
var wordLength = this.word.length;
var result = this.word.substring(0,1).toUpperCase() +
this.word.substring(1,wordLength);

this.word = result;
}
function titlestr(word)
{
this.word = word;
this.titleCase = titleCase;
}
function testwrite()
{
var testword = new titlestr("test");
testword.titleCase();
document.wrtln(testword.word);
}

then in the body you simply put in

<script>testwrite();</script>

Of course, I still need to do a little bit more work to make it
handle multiple words and so on, but the basic idea works. I
wrote the answer based on some info on netscapes web-site in a
discussion of custom objects.

I was really suprised at some of what you can do with them. I am
looking at making other scripts I have written more Object
Oriented using this technique.

Regards
Mike H.




Your Reply

*Your name:
*Message subject:
Home page title:
Home page URL:
Email:
(if you'd like to receive automatic replies by email)