Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascript If else if conflict?
Old 02-04-2008, 02:54 AM Javascript If else if conflict?
Skilled Talker

Posts: 52
Name: Bruce
Trades: 0
I didn't know that a conflict could happen with Javascript if else if code.
I thought after one of the if statements was found to be true that it stopped reading the rest of the if else's and executed it.

I guess it's different when you have it in the head and it just loads automatically without calling it from a function or using it in the body with an onclick or href.

I was trying to write the code more efficient where not as many things were checked to be true or false. So I can't do that when it's in the head and runs automatically huh?
SillyWilly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-04-2008, 11:38 AM Re: Javascript If else if conflict?
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Try posting your code instead of a nebulous description. It's likely that you have a syntax error.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 02-04-2008, 11:45 AM Re: Javascript If else if conflict?
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
I'd agree with Jeremy. It sounds like you've coded something incorrectly, it didn't do what you thought it should, and now you're upset.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-05-2008, 06:42 AM Re: Javascript If else if conflict?
Junior Talker

Posts: 1
Trades: 0
Yes iam also agree with you this same is happened to me many times, the call was going into both if and else at the same time then i used else if to solve the problem......
aashish757 is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 07:32 AM Re: Javascript If else if conflict?
Skilled Talker

Posts: 52
Name: Bruce
Trades: 0
Well, I was simply wanting to know if one can have else if statements in a script where more than one would be true.

I'm positive my code is correct. It worked perfectly after I eliminated the conflict.

I guess you can only use conflicting else if statements in a function, but not in if else statements that will be called automatically unless the script will no longer be on the page to keep running such as when using window.location. I'm correct on this right?

Sorry that I wasn't more clear on my question; I was very sleepy when I posted it. Thanks for offering to help though.

Last edited by SillyWilly; 02-05-2008 at 07:48 AM..
SillyWilly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript If else if conflict?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42396 seconds with 12 queries