Solved

Removing Line Breaks from a String

Posted on 2004-03-31
4
1,648 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

756 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