Forum Moderators: open
Bob Jones
Steve Wilson
Pete Hummer
Sally Smith
Four names.
But if the user enter one more CR at the end of the list my code reads 5 names.
var names = String(Request("names"));
var mbmrs = String(names).split("\r");
var nummbr = mbmrs.length;
I'm trying to find that "\r" using lastIndexOf, or even charAt or charCodeAt but it doesn't find it at the end of the string so I can adjust nummbr.
Any thoughts?
[edited by: txbakers at 11:55 pm (utc) on Feb. 8, 2004]
if (names.lastIndexOf("\r") > -1) {
var bill = names.length -1;
bill--;
names = names.substr(0,bill);
}
this gives me the correct number of names. But why do I need to take the length down one, then decrement bill again? That seems like I would need to take it down twice.
If I use bill = names.length - 2 it cuts off the last letter of the last name.