iLTC Home
Bookmark iLTC!
iLTC Google Boards

Categories

Perl
  • Perl Tutorials Beginners

    Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

    HTML
  • HTML Tutorials



  • iLoveTheCode.com
    Javascript > Javascript Tutorials How To Easy > Get String Length with Javascript

    Get String Length with Javascript



    To get string length with Javascript:

    ko="I will count this string now!";

    ji=ko.length;

    document.write(ji);

    Which Prints:
    29


    -We create a variable and named it ko because we like short names.
    -We created a new variable and named it ji.
    -We used Javascript's built-in length method on ko and stored it's value in ji.
    -We printed to the brower using Javascript's document.write.


    If you wanted to be showy, you could shorten this code like so:

    ji="I will count this string now!" .length;

    document.write(ji);

    Which Prints:
    29

    -Here, we just applied Javascript's built-in length method directly to the string we wanted a count on.
    -Stored it in ji and printed.


    Free Copy and Paste Javascript Code:

    <script type="text/javascript">
    <!--

    ko="I will count this string now!";
    ji=ko.length;
    document.write(ji);

    ji="NO, I will count THIS string now!" .length;
    document.write(ji);

    -->
    </script>



    Resources:
    www.quirksmode.org - Great Resource on Strings and Javascript
    PRINT to Browser with document.write Command in Javascript




    Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
    Previous Article: Use onLoad to Call More than One Function with Javascript
    Next Article: Mimic Typing from a Textfield in a Textarea with Javascript





    CSSCSS

    David McFarland

    New $23.09

    Dreamweaver CS3Dreamweaver CS3

    David McFarland

    New $29.69

    HTML, XHTML, and CSS All...HTML, XHTML, and CSS All-in-One Desk...

    Andy Harris, Chris...

    New $23.09

    JavaScriptJavaScript

    David Flanagan

    New $31.49

    Beginning Joomla!Beginning Joomla!

    Dan Rahmel

    New $29.69

    CSS MasteryCSS Mastery

    Andy Budd, Simon C...

    New $23.09

    Learning Web DesignLearning Web Design

    Jennifer Niederst ...

    New $29.69

    CSSCSS

    Eric Meyer

    New $29.69


    Of Interest:
  • Exit a Script or Subroutine in Perl
  • Passing a Variable or Value to a Subroutine in Perl
  • Create or Put Items into an Array in Perl
  • Write a WHILE LOOP in Perl, Carefully
  • Change a Form Field with Javascript
  • Increment a Variable in Javascript
  • Use onLoad in Body Tag with Javascript
  • Javascript Status Bar
  • HTML Space
  • HTML Superscript Text
  • HTML Status
  • Make Strikethrough Text Using HTML

  • More Articles:
  • Passing a Variable or Value to a Subroutine in Perl
  • Exit a Script or Subroutine in Perl
  • Combine, Put Two Arrays Together in Perl
  • Delete a File Using unlink in Perl
  • onClick Javascript
  • Annoy Users with onBlur in Javascript
  • Environmental Variables Available in Javascript using Navigator Object
  • Opening a REMOTE WINDOW in Javascript
  • Use OnMouseOver in Javascript
  • HTML Body Tag
  • HTML Color Codes
  • HTML Forms
  • Make a New Paragraph Using HTML

  • Search iLTC w/ Google





    Recent Articles

  • Javascript Focus Form Field
  • Javascript Lowercase Text
  • Javascript Uppercase Text
  • Javascript Superscript Text
  • Javascript Subscript Text
  • Make Text Blink Using Javascript
  • Make a String into a Link in Javascript
  • Javascript Italics Text
  • Javascript Bold Text
  • Javascript Redirect
  • HTML Frames
  • HTML Color Chart
  • HTML Link
  • Javascript Status Bar








  • Perl Programming - Javascript Programming - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006 iLoveTheCode.com


    Contact Chris | About this Site


    581,349
    Counter by iLoveTheCode.com


    Last Modified: Friday, 23-Jun-2006 07:23:13 EDT