9 Replies Latest reply on Jun 7, 2006 5:51 AM by llion

    Simple GET form (input text variable problem)

    llion
      I'm trying to move some info from flash to another page, it should be really simple.

      All i have is an input text field and a button, the input text has the instance name search_txt

      I have this code on the button

      on (click) {;
      searchText=search_txt
      searchON = "OK"
      getURL("search.php", "_self", "GET");
      }

      the searchON is just a variable i need for the php - and that works fine
      but for searchText i get searchText=undefined

      so i'm guessing i need to do something like define it as a variable, where and how should i do this?

      what i want as an outcome is search.php? searchText=whatever was in the input text field&theRestOfTheStuff

      thanks for any help
        • 1. Re: Simple GET form (input text variable problem)
          blemmo Level 1
          Hi,

          search_txt is the name of the textfield, the text it holds is in the 'text' property:

          on (click) {
          searchText = search_txt.text;
          searchON = "OK";
          getURL("search.php", "_self", "GET");
          }

          If you have a lot of other vars in your movie, getURL might be not so good, because it sends every var in the movie. Have a look at the LoadVars class, it gives you more control about what's getting sent.

          cheers,
          blemmo
          • 2. Re: Simple GET form (input text variable problem)
            llion Level 1
            searchText = search_txt.text;
            yup, already tried that one and i still get undefined as an output

            any further ideas?

            I'm going to change it to post after i've worked this out - it's only on get so i can see what exactly the whole thing is outputting
            • 3. Re: Simple GET form (input text variable problem)
              blemmo Level 1
              Hm, try
              searchText = _root.search_txt.text;
              or instead of _root the full path to the textfield.
              If it still won't work, you could try to assign a variable to the textfield, and use this to get to the text. I had some cases too where I couldn't get to the text via the 'text' property, dunno why.

              hth,
              blemmo
              • 4. Re: Simple GET form (input text variable problem)
                llion Level 1
                ok something's happened... but not the right result... yet

                i changed it to _root.search_txt.text; as you suggested

                and then i took out the defalut text from the textbox, and now when i go to the page the default text is _level0.search_txt

                if i leave this in i'm returned &searchText=%5Flevel0%2Esearch%5Ftxt
                which would be the desired result if that's what i'd typed.

                but whenever i change this to my own text i just get 'undefined' again

                (changing the code to searchText = _level0.search_txt.text; doesn't help either)

                would it be any help to you if i post you the link and fla file?
                • 5. Re: Simple GET form (input text variable problem)
                  blemmo Level 1
                  Strange... I setup a movie as you described, just a textfield and a button, and it worked right away. When I used this line:
                  searchText=search_txt
                  then I got the result you described in your last post, searchText=%5Flevel0%2Esearch%5Ftxt. When I used
                  searchText=search_txt.text
                  it did as expected and the output was searchText=xxx, whatever the input was.

                  Maybe you can upload your fla, now I'm curious what's wrong here.
                  • 6. Simple GET form (input text variable problem)
                    llion Level 1
                    ok i think my brain is frying trying to get over this, i couldn't even see how to upload the fla to the forum...

                    so here's a link to get it from my site

                    [EDIT - removed link after it was used]
                    • 7. Re: Simple GET form (input text variable problem)
                      blemmo Level 1
                      You shouldn't have vars with the same name as object instances, guess that's the reason for the strange things in your last post.
                      I deleted the var assigned to the textfield, and used
                      searchText = _root.search_txt.text;
                      this gets the text from the textfield. You can check this with a trace:

                      on (click) {
                      trace(_root.search_txt.text);
                      searchText = _root.search_txt.text;
                      searchON = "OK"
                      getURL("search.php", "_self", "GET");
                      }

                      However, it didn't open a new site when testing... Another reason why I never use components, they just behave strange too often. I recommend using the standard buttons or MCs with the onRelease event, if you don't need the special visual style the button components are providing.

                      cheers,
                      blemmo
                      • 8. Re: Simple GET form (input text variable problem)
                        blemmo Level 1
                        ok, when using
                        _root.getURL("search.php", "_self", "GET");
                        the window opens. Finally all is working
                        • 9. Re: Simple GET form (input text variable problem)
                          llion Level 1
                          Quality, that's done it. and no i don't need the visual stuff. i'm actually applying it to a banner to which i've already put all the graphics on. (but thought it would be easier to work out what i was doing on the most basic of basic sheets first then apply to the banner). so i'm now using an onRelease event and that works too.

                          Thanks very much!!