JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 27th, 2004, 06:29 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
combine a javascript if together

this is what i have now

if (selectVal.value == 'Rental House') {
document.getElementById('rental_table').style.disp lay='';
document.getElementById('main_table').style.displa y='none';
}
else if (selectVal.value == 'Rental Unit') {
document.getElementById('rental_table').style.disp lay='';
document.getElementById('main_table').style.displa y='none';
}

is there a way i can combine it like this.

if (selectVal.value == 'Rental House',***or***'Rental Unit') {
document.getElementById('rental_table').style.disp lay='';
document.getElementById('main_table').style.displa y='none';
}

just that i have more like this for example i need to create one
that will have 5 if else and it gets very confusing..


cheers aron.

Reply With Quote
  #2  
Old January 27th, 2004, 06:52 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
simply put || inbetween the statements

if (selectVal.value == 'Rental House' || 'Rental Unit') {

|| is or

&& is and

Reply With Quote
  #3  
Old January 27th, 2004, 07:03 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
If you wanted to do something different, depending on the value, you would be better to use a "switch" statement (commonly called a "case" statement)... otherwise, if the action to be taken is the same for all, then use the above suggestion.

Reply With Quote
  #4  
Old January 27th, 2004, 07:12 PM
aron aron is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: brisbane
Posts: 42 aron User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 9 m 35 sec
Reputation Power: 5
same as php cool thanks.

aron.

Reply With Quote
  #5  
Old January 27th, 2004, 09:04 PM
DocLogic DocLogic is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Wadsworth, OH
Posts: 10 DocLogic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by Bruski
simply put || inbetween the statements

if (selectVal.value == 'Rental House' || 'Rental Unit') {

|| is or

&& is and



REALLY??

the || operator works like that?

I would have done

if( selectVal.value == 'Rental House' || selectVal.value == 'Rental Unit') {

Reply With Quote
  #6  
Old January 27th, 2004, 10:44 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
oops my mistake =[

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > combine a javascript if together


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT