Click to See Complete Forum and Search --> : Javascript - Err: expecting")" -THERE!


slynx
01-24-2003, 08:48 PM
I would be grateful for any enlightenment on this problem ... according to all the books & online material I've referenced, this "should" work ... but I get a Javascript Error: expecting ")"


for(i=1; i<50; i++)
{
var compchap = chapter[i];
//alert(chapter[i]);
//}

==> if ( psswd != compchap ) {
alert('Only membersETC.');
}
else
{
alert('Welcome, ETC.');
}
}

The code works fine up to the line with ==>
(checked by uncommenting the alert(chapter[i]); and commenting out the if statement ... also gives the "else" alert if that isn't commented out. I have also tried changing the condition in the if statement = same error.

One of the iterations of the script is at:
http://www.reinuse.com/MEV/

Jona
01-24-2003, 08:51 PM
Uh... maybe..

==> if((psswd != chomchap))

I'm not sure, that looks odd...

slynx
01-24-2003, 08:53 PM
Thanks for the input Jona .... I tried double ()s ... still get:

Error: ")" expected

Jona
01-24-2003, 08:54 PM
Does it say which line and char?


BTW, you're from Ohio??? COOL!

Jona
01-24-2003, 09:05 PM
Try it without using spaces, and only one ().

slynx
01-24-2003, 09:11 PM
Yes ... it says line 112 .... which is the one I put the ==> at.

The error is " Error: expected ")" "

I have tried it without spaces, with double and single ()s, tried changing the condition, flipped the if & else statements & made the if statement == instead of !=, even set the condition to i=3 ....



No matter what I do, I get that same error for that one line.


Yes, I'm from Ohio .... it's not just cool, it's freezing here! :D

Jona
01-24-2003, 09:18 PM
Funny, slynx! :D

Back to your problem, though. I have viewed the site with that, and I'm not exactly sure of the problem. Nothing, at the current time, makes sense to me.

We have an Array, and we loop it with "for(i)" Then, we check to see, "if the username exists, if it does, check the password, if not, alert the user." Then, we check the password, "does it exist?" If so, send the user to the next page, if not, alert saying so.

The logic seems fine to me. I think there may be a problem in the variable area...

jeffmott
01-24-2003, 09:29 PM
http://www.reinuse.com/MEV/
alert('Welcome, TTT Society Member, ' + mmname + '\nMev - At this point, redirection to members' only pages can occur.');
Check your quotes.

Jona
01-24-2003, 09:35 PM
Shouldn't it have said, "Unterminated String Constant" instead? OH well...

slynx
01-25-2003, 11:07 AM
Thanks guys! The apostrphe within the alert message was the problem. Could have sworn I checked all quotes ....



Everything is up an working perfectly now.