|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
simply put || inbetween the statements
if (selectVal.value == 'Rental House' || 'Rental Unit') { || is or && is and |
|
#3
|
||||
|
||||
|
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.
|
|
#4
|
|||
|
|||
|
same as php cool thanks.
aron. |
|
#5
|
|||
|
|||
|
Quote:
REALLY?? the || operator works like that? I would have done if( selectVal.value == 'Rental House' || selectVal.value == 'Rental Unit') { |
|
#6
|
|||
|
|||
|
oops my mistake =[
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > combine a javascript if together |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|