Truncating last character in a string
by schefz » Fri, 19 Oct 2007 02:31:45 GMT
I am making a dialpad. It is just for display so I am using a string for the
numbers selected. I am trying to make a back button that would clear the last
number added. I tried mystring.length-1 but that doesn't seem to be doing the
trick. Is there a simple way to truncate the last character in a string, of
variable length??
Re: Truncating last character in a string
by GWD » Fri, 19 Oct 2007 04:33:27 GMT
Here's an example
var someStr="asdfasdf saf asdf sadfas dfs fsa asf";
while (someStr.length) {
someStr = someStr.substring(0,someStr.length-1)
trace(someStr);
}
Re: Truncating last character in a string
by schefz » Fri, 19 Oct 2007 08:55:07 GMT
thank you GWD!! once again you have helped me solve my problems.. I might have to start calling you Dr. Phill :-)
Similar Threads:
1.Input text - losing last character
Nubie (and hopefully, easy) question - my input text fields all fail to capture
the last character typed into the text field. I'm currently asking users to
hit the <ENTER> key before submitting their input (and this works because then
ENTER becomes the final character), but there must be some simple fix that I'm
missing.
Here's a code example:
Answer_a.type = TextFieldType.INPUT;
addChild(Answer_a);
Answer_a.addEventListener(TextEvent.TEXT_INPUT, textInputCapture);
function textInputCapture(event:TextEvent):void {
submit_answer = Answer_a.text;
}
2.Deleting last char in string
Hey guys and girls, I'm new to this actionscript thing and have used various
other languages. All I want to do is find the last character in a string and
delete it. Essentially what the backspace key does. But I can't work this out
using the string class. Do I have to convert to an array? thanks in advance
for any help offered people. TUUK
3.Replacing characters in a string.
I am passing a string to a sql server database from within flash as a query, I
have mostly successfully queried the database, but have had problems with
queries that contain certain characters (such as pipes |, or '&') is there a
way I can replace these characters before passing the query string to the
database?
:confused;
4.I can't POST a variable (string) which contains greek characters correctly
I have a problem posting string variables from a flash movie to an ASP file.
When the ASP file recieves the posted variable, the text looks ok only when I
am posting english characters.
I can't POST a string variable with greek characters to an ASP or CFM file.
For example...
At Flash movie (ActionScript)...
var topostit = "<greek characters>";
getURL("receiver.asp","_blank","POST");
At ASP file (JavaScript)...
var topostit=Request.Form('topostit')();
Response.Write(topostit);
When topostit="English" then ASP file gives "English"
When topostit="<greek characters>" then ASP file gives "#^%$^$$$#"
Please tell me if you know the answer to this problem.
5.Passing Special characters in string from html to flash
6. Search String For Characters
7. special characters in strings and text feilds
8. Replacing String Characters