Solved

Removing Line Breaks from a String

Posted on 2004-03-31
4
1,649 Views
Last Modified: 2012-08-14
I have an input form built in flash.

There is an address field  on the form and it is multiline which allows the user to hit return/enter to move to the next line and continue their address.

WHen the user hits submit on the form i want to remove the line breaks before i send the data.

how do i remove the line breaks????????
0
Comment
Question by:Fatlog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 9

Expert Comment

by:krishnaprathab
ID: 10724977
Hi,

  You can use escape(myText.text) which gives you teh URL encoded string.

Example :

Suppose I enter the below mentioned text in my input text box foor which the instance name is myText :

John
270, Wall Street,
Washington

and affix the action below on a button:

on (release) {
      trace(escape(myText.text));
}

the Ouput is :
John%0D270%2C%20Wall%20Street%2C%0DWashington

Since, this is already URL Encoded you can directly send the data to the URL or you can use a string manipulation fucntion to get rid of yur %0D and  %DC stuffs.

Hope this helps !

Thanks,
-KP
0
 

Author Comment

by:Fatlog
ID: 10730669
this doesnt really work

i need to be able to do something like the way you can use split/join to replace characters
0
 
LVL 9

Expert Comment

by:krishnaprathab
ID: 10730828
Hi,

 Please upload your file to some location and let me know. I will correct it and give you.

Thanks,
KP
0
 
LVL 9

Accepted Solution

by:
krishnaprathab earned 25 total points
ID: 10773412
One more try:

1) Write the below listed function in your root timleine (I have not written this code I found it in Actionscript.org)

String.prototype.searchreplace=function(find,replace) {
        var string=this
        var counter
        while (counter<string.length) {
                var start = string.indexOf(find, counter);
                if (start == -1) {
                        break;
                } else {
                        var before=string.substr(0,start)
                        var after=string.substr(start+find.length,string.length)
                        string=before+replace+after;
                        var counter=before.length+replace.length
                       
                }
        }
        return string;
}

2) On your buttons onRelease event write the action :

on (release) {
      myStr = escape(myText.text);
      myStr = myStr.searchreplace("%20"," ");
      myStr = myStr.searchreplace("%0D",",");
      myStr = myStr.searchreplace("%2C",",");
      trace(myStr);
}

3) Restrict your input text field to only numbers and characters.

4) Now when you type :

John Greenhow
120 Wall Street
Washington DC

in the input text field and click on the button it will trace :

John Greenhow,120 Wall Street,Washington DC

There is no other way to achive what you want.

Hope this helps !

PN: Please close this question.

Thanks,
KP
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Stock Videos 17 352
How to display a webpage in a flash 10 384
Online Course Not Responding 3 97
You Tube Videos not playing 9 143
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question