A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Script help

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702

    Script help

    What is wrong with this script?

    if element("email")="email"{
    show(element ("Error"));
    }
    else
    {
    loadVariables("http://www.website.com/script.php","POST")
    }

    What I want this script to do is, check an EDIT BOX with the Variable "Edit" and see if it has the word "email" in it.

    If it does, I want it to load a layer that I created with an error message.

    Otherwise, send the variables to my php file.

  2. #2
    hates sounds in preloaders.
    Join Date
    Nov 2002
    Location
    Sweden
    Posts
    361
    First, assign your element to a variable, in the start script:

    error = element ("error");


    Then, so like this...

    if (Edit == "email"){
    error.show();
    }
    else {
    loadVariables("http://www.website.com/script.php","POST")
    }

    I've nver tested loadVariables, but i hop this'll work.

    Joel

    *Edit* Sorry, made a little typo...

    Joel
    hurg.

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Nope, still doesn't work...
    Strange thing...the else statement DOES work.

    Here is the script that I tried.

    //begin conditions

    if (element ("email")=="email")
    {
    error=element("Error");
    error.show();
    }
    else
    {
    loadVariables("http://www.pmedic.com/compumedic/job.php","POST");
    success_submit=element("Success");
    success_submit.show();
    }

    I also tried you IF condition...no dice.

  4. #4
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    you cant use if(element("aaaa") == anything) at all

    element("aaaa") is a command used to declare, not for testing a condition
    your code should be like this

    create an edit box. It has a variable name - lets set it to be myvar




    error=element("Error"); //..place this in the main javascript


    // now place this code in a button for submit form testing

    if (myvar=="email")
    {
    loadVariables("http://www.pmedic.com/compumedic/job.php","POST");
    success_submit=element("Success");
    success_submit.show();
    }
    else
    {
    error.show();
    }



    The code above assumes that if we typed email into the edit box then we loadvariable else we show an error.

  5. #5
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    That didn't work either...

  6. #6
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    Is it possible that the element you want to show is hidden behind another element?

    Is it the show part that does not work or the loadvariables?
    What happens when you put debug statements in ? can you determine if the IF statement is testing true?

    perhaps you could post the movie here. I do know what its like to have a hard time debugging a problem, I am currently having trouble with some navigate code and its easy to overlook something you thought was insignificant or already working when in fact its the actual problem.

  7. #7
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Here is the movie file that I've been working on.

    I've put the IF Statement in the BUTTON DOWN action of the submit button.

    Problems:
    Without the IF statements...the loadVariables works fine. Once I create the if statement, it doesn't.

    AND the error message that is supposed to open up if the edit box with variable(email) has the text "email" in it, doesn't open up.

    The success message does open.

    I'm so confused.

  8. #8
    Senior Member
    Join Date
    Mar 2003
    Posts
    136
    Sorry for the delay, as I am deep in other stuff as well.

    I ran the movie with the LoadVariables code commented out and a debug statement in its place.

    When I run it the program crashes out of the runtime back into the 3dfa editor, when I click on the submit button.

    I'll try again later and add more debugging to see what gives.

    Nice form by the way , including the submit buttons.

  9. #9
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Originally posted by dniezby
    AND the error message that is supposed to open up if the edit box with variable(email) has the text "email" in it, doesn't open up.

    The success message does open.

    I'm so confused.
    I found your error The word error is reserved word you can't use it as an element name or variable in a script.

    Change that to something else and it works fine.

    You might notice it turned a color, that's the first hint. The other thing to do when you are having problems with a bit of code is to use the TRACE feature.... You put a trace("var") before your if and inside the if {} to keep an eye on the value......

    Trace is very usefull when debugging.

  10. #10
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    WELL I'LL BE DAMNED!!!!!!!

    How did I not catch that.

    You won't believe the amount of hair I've pulled out trying to figure out what I thought was a simple problem...Well, I was right, it was a simple problem.

    DAMN!!


    THANK YOU BRET!

  11. #11
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    No Problem, I like when I have the answer....

    It's the ones where I'm asked to do a complete program for someone as an answer I don't handle too well

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center