<HTML>
<HEAD>
<SCRIPT>
function capWords(str){
words = str.split(" ");
for (i=0 ; i < words.length ; i++){
testwd = words[i];
firLet = testwd.substr(0,1);
rest = testwd.substr(1, testwd.length -1)
words[i] = firLet.toUpperCase() + rest
}
document.theForm.results.value = words.join(" ");
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="theForm">
Enter a text string:
<TEXTAREA name=inStr rows=5 cols=90>
</TEXTAREA>
<INPUT type=button value="Capitalize Words" onClick="capWords(document.theForm.inStr.value)";>
<INPUT type=button value="Clear" onClick='document.theForm.inStr.value=""';>
<TEXTAREA name=results rows=5 cols=90>
</TEXTAREA>
</FORM>
</BODY>
</HTML>
|