Solved

Script problem

Posted on 2006-06-12
3
200 Views
Last Modified: 2010-04-03
Hi experts,

This script is working fine with one ' but when I have two of them it removes the first one... What should I do?

function stringHTML1(s) {
      var my_str = new String(s);
      var my_array = my_str.split("'");
      var tmp_str = "";
      if (my_array.length != 1) {
            for (var i = 0; i<my_array.length; i++) {
                  tmp_str += my_array[i];
                  if (i == my_array.length-2) {
                        tmp_str += "'";
                  }
            }
            return tmp_str;
      } else {
            return s;
      }
}
0
Comment
Question by:cabou
3 Comments
 
LVL 7

Accepted Solution

by:
furmiga earned 250 total points
ID: 16889495
Hi there

i tried this and it might be what you are looking for

function stringHTML1(s)
{
    var my_str = new String(s);
    var my_array = my_str.split("&apos;");
    var tmp_str = "";
    if (my_array.length != 1)
    {
        for (var i = 0; i<my_array.length; i++)
        {
          tmp_str += my_array[i];
          if (i+1 < my_array.length)
          {
                tmp_str += "'";
          }
        }
        return tmp_str;
        //trace(tmp_str);
    }
    else
    {
        return s;
    }
}

i made a button

    on(release)
{
      stringHTML1('1111111111&apos;2222222222&apos;3333333333')
}

traced 1111111111'2222222222'3333333333

is this what you want ?
}
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16890889
If you mean to say, that when you have two functions then first one is gets replaced with second one....

if yes, then here is the solution:
--------------
you should use different name for both functions:

function stringHTML1(s) {
 /// code here
}

function stringHTML2(s) {
 /// code here
}

:-Aneesh
0
 

Author Comment

by:cabou
ID: 16891995
Hi,

Again great work

few things:

1)I need to be able to use "apos", please include the function to do it like in the previous flash. They were a problem with your function, please use the following.

function stringHTML1(s)
{
    var my_str = new String(s);
    var my_array = my_str.split("&apos;");
    var tmp_str = "";
    if (my_array.length != 1)
    {
        for (var i = 0; i<my_array.length; i++)
        {
         tmp_str += my_array[i];
         if (i+1 < my_array.length)
         {
                tmp_str += "'";
         }
        }
        return tmp_str;
        //trace(tmp_str);
    }
    else
    {
        return s;
    }
}

2) The links are not working (they also need to open in the same page)

3) Can you please ad a param, so I can have a diferent background on the link page.

4) to finish can you please ad a 1px black borber when the mouse is over a label-link

Again thanks a lot

Erez
0

Featured Post

Technology Partners: 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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
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…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

749 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