Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-06-2005, 09:57 AM   PM User | #1
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
Question Proper Case

Code:
forename.toUpperCase()
Is there a way to change this value to Proper Case, i.e. forename = picco
change to Picco
crmpicco is offline   Reply With Quote
Old 07-06-2005, 10:29 AM   PM User | #2
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
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
martin_narg is offline   Reply With Quote
Old 07-06-2005, 01:11 PM   PM User | #3
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
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++)
	{
	}
crmpicco is offline   Reply With Quote
Old 07-06-2005, 01:16 PM   PM User | #4
crmpicco
Senior Coder

 
crmpicco's Avatar
 
Join Date: Jan 2005
Location: Mauchline, Scotland
Posts: 1,091
Thanks: 15
Thanked 1 Time in 1 Post
crmpicco has a little shameless behaviour in the past
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++)
	{
crmpicco is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:23 PM.


Advertisement
Log in to turn off these ads.