5 Replies Latest reply on Jan 30, 2007 8:57 PM by Marghoob Suleman

    make a variable a url link

    Level 7
      How can I make the variable locale[p] a url link, and the address of the
      url would be locale[p] ?

      if(locale[p] != "none") {
      myText = myText + "<b>location:</b>" + locale[p]+newline;
      }

      Thank you

        • 1. Re: make a variable a url link
          MotionMaker Level 1
          Note: locale[p] is not a variable. There are two variables: locale and p. So what are you asking?

          Assuming locale is an array
          var locale:Array = new Array()
          locale.push(" http://www.yourdomain.com");
          var p:Number = 0;
          trace (locale[p])

          But are you thinking locale as an object -- hard to tell.
          var locale:Object = new Object()
          locale.p = " http://www.yourdomain.com";
          trace (locale.p)

          • 2. Re: make a variable a url link
            Level 7
            Thank you for your response.
            yes, locale is in an array and p represents where in the array it is.
            What I'm trying to do is whatever locale[p] is (a url coming from an xml
            file), I want it to be a clickable link when it is listed.
            Once that text is clicked, new window in browser opens to that address.

            Heres are 3 incomplete portions of the code on the page to help me show you
            what I'm talking about:

            function loadXML(loaded) {
            if (loaded) {
            xmlNode = this.firstChild;
            image = [];
            description = [];
            thumbnails = [];
            notes = [];
            locale = [];


            for (i=0; i<total; i++) {
            image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
            description =
            xmlNode.childNodes
            .childNodes[1].firstChild.nodeValue;
            thumbnails = xmlNode.childNodes.childNodes[2].firstChild.nodeValue;
            notes = xmlNode.childNodes.childNodes[3].firstChild.nodeValue;
            locale = xmlNode.childNodes.childNodes[18].firstChild.nodeValue;


            if(use[p] != "none") {
            myText = myText + "<b>Use:</b>" + use[p]+newline;
            }
            if(locale[p] != "none") {
            myText = myText + "<b>location:</b>" + locale[p]+newline;
            }
            if(completion[p] != "none") {
            myText = myText + "<b>completion:</b>" + completion[p]+newline;
            }
            if(services[p] != "none") {
            myText = myText + "<b>services:</b>" + services[p]+newline;

            }

            "MotionMaker" <webforumsuser@macromedia.com> wrote in message
            news:eplka0$gi8$1@forums.macromedia.com...
            > Note: locale[p] is not a variable. There are two variables: locale and p.
            > So
            > what are you asking?
            >
            > Assuming locale is an array
            > var locale:Array = new Array()
            > locale.push(" http://www.yourdomain.com");
            > var p:Number = 0;
            > trace (locale[p])
            >
            > But are you thinking locale as an object -- hard to tell.
            > var locale:Object = new Object()
            > locale.p = " http://www.yourdomain.com";
            > trace (locale.p)
            >
            >
            >

            • 3. Re: make a variable a url link
              Marghoob Suleman Level 1
              Here is an example... you need to write a href code for each link.

              • 4. Re: make a variable a url link
                Level 7
                Marghoob,
                Thank you for your reply It helped a great deal.
                I am almost there.
                I used:
                if(floorplan[p] != "none") {
                myText = myText + "<b>floorplan:</b>" + (url = "<a
                href='"+floorplan[p]+"'>"+floorplan[p]+"</a>");
                }
                The above put the variable floorplan[p] as the address in the url and made
                it clickable. Good.
                I would like to open a new browser window when it is clicked.
                Can't get "_blank" to work. Not sure where to place it or use some other
                code instead of "_blank"?



                "Marghoob Sulemaan" <webforumsuser@macromedia.com> wrote in message
                news:epn2vq$77k$1@forums.macromedia.com...
                > Here is an example... you need to write a href code for each link.
                >
                >
                >
                > var url = " http://www.yahoo.com/";
                > url = "<a href='"+url+"'>"+url+"</a>";
                >
                > this.createTextField("myText_txt",10,10,10,200,100)
                > with(myText_txt) {
                > border = true
                > html = true;
                > htmlText = url;
                > }
                >

                • 5. Re: make a variable a url link
                  Marghoob Suleman Level 1
                  You welcome Joe :)
                  myText = myText + "<b>floorplan:</b>" + (url = "<a href='"+floorplan[p]+"' target='_blank'>"+floorplan[p]+"</a>");

                  it will work...