Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 31-10-2009
Member
 
Join Date: Aug 2009
Posts: 36
Get String Length with Javascript

I am writing JavaScripts and i need to know what strings are and how they work. I have tried to create a code to find the length of a string with str.length() function but gives error. Can any one tell me how to find the length of a string in JavaScripts.
Reply With Quote
  #2  
Old 31-10-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Get String Length with Javascript

Code:
<script type="text/javascript">
var myString = "12345678";

var length = mstr.length;

document.write("The string length : " + length);

document.write("<br />The string is this long: " + myString.length);

</script>
Output :
Code:
The string is this long: 8
The string is this long: 8
Reply With Quote
  #3  
Old 31-10-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: Get String Length with Javascript

Javascript string length :

The following example uses the length property of the String object to find the length of a string:var txt="string";
document.write(text1.length);

The code above will result in the following output:6

The following example uses the toUpperCase() method of the String object to convert a string to uppercase letters:var txt="string";document.write(txt.toUpperCase());

The code above will result in the following output:string
Reply With Quote
  #4  
Old 31-10-2009
Member
 
Join Date: Dec 2008
Posts: 177
Re: Get String Length with Javascript

Strings are simply groups of characters, like 'JavaScript', 'string',
Code:
<script language="javascript" type="text/javascript">

var len=" length of chracter";
alert(len.length);

</script>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Get String Length with Javascript"
Thread Thread Starter Forum Replies Last Post
Coversion of Cast string as int in Javascript LaMarcus Software Development 5 14-10-2010 03:59 AM
Finding php string length afidelino Software Development 5 26-02-2010 07:34 PM
Find and Replace in JavaScript String Wilbur Software Development 5 15-12-2009 02:23 PM
Trim a String in JavaScript Kingfisher Software Development 3 21-11-2009 10:32 AM
Length of a string displayable in C Berlin Baby Software Development 3 10-01-2009 07:06 PM


All times are GMT +5.5. The time now is 04:48 PM.