Convert a Letter UPPERCASE

[Total: 1    Average: 5/5]

This example will change one letter of your choice per function call from lower case to upper case.

Body Code:

<script>
function toUp(tci,ch)
{
  var result="";
  if(tci.value.indexOf(ch)==-1)
    /* Looking for the CHARACTER if it exits then dont do anything */
    tci.value = tci.value;
  else
  {
    /* Character Exists */
    var str = tci.value.split('');
    for(i=0; i<=str.length-1; i++)
	{
	  if(str[i]==ch)
        /* here update the Character within the LOOP */
        str[i]  = str[i].toUpperCase();
      /* save the output to the resule variable which was set to a blank string in the begining */
      result+=str[i];
    }
    /* and Finaly set the value of your textBox equall to the result variable */	
    tci.value = result;
  }
}
</script>

This example looks for the letter "s" to change to upper case.
<form method="POST" name="f1">
<BR><input type="text" name="t1" size="20">
<BR><input type="button" value="Update" name="B1" onClick="toUp(t1,'s')">
<input type="reset" value="Reset" name="B2">
</form>

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *