Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Proper Case

  1. #1
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,097
    Thanks
    15
    Thanked 1 Time in 1 Post

    Question Proper Case

    Code:
    forename.toUpperCase()
    Is there a way to change this value to Proper Case, i.e. forename = picco
    change to Picco

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Code:
    <script>
    String.prototype.capitalize = function() {
    	return this.charAt(0).toUpperCase() + this.substring(1,this.length).toLowerCase();
    }
    </script>
    Usage:

    Code:
    var str = "martin_narg";
    var string1 = str.capitalize();
    // output is Martin_narg
    
    // or
    
    var string2 = ("martin_narg").capitalize();
    // output = Martin_narg
    This is an extension to the string object, so you can use it with any JavaScript string without repeating the code.

    Hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,097
    Thanks
    15
    Thanked 1 Time in 1 Post
    i need to change the start of this for loop depending on a condition
    how do i do that? this code doesnt work.
    Code:
    if(document.form.nochd==1)
    	{
    	for (i=0; i<document.form.nochd.value; i++)
    	{
    	}
    	else
    	{
    	for (i=0; i<document.form.nochd.value-1; i++)
    	{
    	}

  • #4
    Senior Coder crmpicco's Avatar
    Join Date
    Jan 2005
    Location
    Mauchline, Scotland
    Posts
    1,097
    Thanks
    15
    Thanked 1 Time in 1 Post
    fix:

    Code:
    if(document.form.nochd.value==1)
    	{
    	nochdvalue=document.form.nochd.value
    	}
    	else
    	{
    	nochdvalue=document.form.nochd.value-1
    	}
    	
    	for (i=0; i<nochdvalue; i++)
    	{


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •