Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > how I add more then one "if" "then" statement to a function

how I add more then one "if" "then" statement to a function
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Oct 4, 2004, 10:05 AM
 
Hi,
Does anyone know how I add more then one "if" "then" statement to a function to cover several possible conditions?


//Sample JS Code
function toggleID(whichOne) {
switch(whichOne) {

case 57:
if (document.getElementById("TV1").style.display != "none") {
document.getElementById("TV1").style.display = "none";
document.getElementById("TS3").style. display = "block";
} else {
document.getElementById("TV1").style.display = "block";
document.getElementById("TS3").style. display = "none";
}
break;

but what if I wanted to add several more conditions like this:

//Sample JS Code
function toggleID(whichOne) {
switch(whichOne) {

case 57:
if (document.getElementById("TV1").style.display != "none") {
document.getElementById("TV1").style.display = "none";
document.getElementById("TS3").style. display = "block";
} else {
document.getElementById("TV1").style.display = "block";
document.getElementById("TS3").style. display = "none";
}if (document.getElementById("TS2").style.display != "none") {
document.getElementById("TS2").style.display = "none";
document.getElementById("TS3").style. display = "block";
} else {
document.getElementById("TS2").style.display = "block";
document.getElementById("TS3").style. display = "none";
}
break;
     
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status: Offline
Reply With Quote
Oct 4, 2004, 10:22 AM
 
Code:
} else if {
??
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Oct 4, 2004, 08:08 PM
 
Thanks skalie, it was enough to point me in the right direction!
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2