Click to See Complete Forum and Search --> : Script help
dniezby
04-11-2003, 07:39 PM
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.
Twisted Mind
04-12-2003, 04:21 AM
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
dniezby
04-12-2003, 04:28 PM
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.
carnwath
04-12-2003, 06:30 PM
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.
dniezby
04-12-2003, 09:04 PM
That didn't work either...
carnwath
04-12-2003, 09:15 PM
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.
dniezby
04-12-2003, 10:04 PM
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.
carnwath
04-13-2003, 03:19 PM
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.
blanius
04-13-2003, 04:04 PM
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.
dniezby
04-13-2003, 04:55 PM
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!
blanius
04-14-2003, 09:13 AM
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 :D
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.