initial caps




JavaScript Source Code 3000: Forms: Initial Caps







































Initial Caps







Converts the first letter of each word in a string that the user enters to uppercase. The remaining letters of each word are also changed to lowercase. Very useful when a form requires a title to be submitted in Initial Caps.














JavaScript Source Code 3000: Forms: Initial Caps
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!





    





<!-- TWO STEPS TO INSTALL INITIAL CAPS:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: William Humphreys (billy@technical-solutions.co.uk) -->

<! >
<! >

<!-- Begin
function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0) {
for (index = 0; index < strLen; index++) {
if (index == 0) {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1)) {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
}
}
}
}
frmObj.value = tmpStr;
}
// End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<BODY>

<center>
<form name=form>
<input type=text name=box value="type in here!">
<input type=button value="Convert" onClick="javascript:changeCase(this.form.box)">
</form>
</center>



<!-- Script Size: 1.54 KB -->














Wyszukiwarka

Podobne podstrony:
initialcontent
initialcontent
clean caps
InitialContextFactoryBuilder
initialcontent
initial
INITIALIZE
InitialContextFactory
Initial Configs r5
dynlayer initialization1
initialcontent
InitialInformationRecord
Plan Remainder of Initial Iteration?FF0FA5
yba initial amp
Initial Configs r6
Luciferian Initiation Via Nocturne

więcej podobnych podstron