[Javascript] length property?

Peter Brunone peter at brunone.com
Wed Apr 25 17:29:59 CDT 2001


Les,

    Do you want to know the value of the number, or the length?  The length
of any string value can be found by the length property, e.g.

var newString = "boo";  // making a string just for fun
var strLength;  // just making a variable to hold the length

    And then...

strLength = newString.length;

    or

strLength = "boo".length;

    or

strLength = document.formName.fieldName.value.length;

    You can use it on any string at all.

Cheers,

Peter

----- Original Message -----
From: "Les & Paula Tingley" <lptingley at mediaone.net>
To: <javascript at LaTech.edu>
Sent: Wednesday, April 25, 2001 5:08 PM
Subject: [Javascript] length property?


> I'm new to javascript and could use some help with a road block on a new
> project.
> I need to determine the number of characters (variable) from a text box
> on a form.
> then use the results in a calculation that gets passed to another form
> field. The form is
> part of a web page for a Motocross Graphics company. I need to calculate
> price for some Racing Numbers. The Numbers are $1 each but the Customer
> would order his/her number by the set (Whatever their number happens to
> be). The owner of the Graphics company wants the user to simply put in
> their number and have the sales price calculated from that field. I
> already have figured out the script to remove any spaces that the user
> might enter. I now need to determine the number of characters in the
> field, multiply it times $1.00 to get the resulting sales price. I had
> attempted to get them to allow me to use a drop down box where the
> customer would select the number of digits that they wanted, but this
> could lead to human error. Does anybody have any clue on how to do this?
>
> Thanks,
> Les





More information about the Javascript mailing list