/    Sign up×
Community /Pin to ProfileBookmark

Switch Problem

var R11; var R12;
switch(document.getElementById(dis1).value){
case”None”:R11=”0.00″;break;
case”Absolute Black”:R11=”675.00″; break;
}

alright that works…

var R11; var R12;
switch(document.getElementById(dis1).value){
case”None”:R11=”0.00″;break;
case”Absolute Black”:R11=”675.00″; break;

if (document.getElementById(‘ADMIN_PLAN’).value ==”Sunny”){
case”special”:R12=”special”;R11=”0.00″;break;}}

that doesnt. why doesnt an if statement work inside a switch? what is my way around it, or is there a less complicatated way?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mutimniauthorNov 19.2004 — Nevermind

you can have a switch inside a case statement...

switch(1){

case"1":

switch(2){

case"2":myvar=Blah;break;

}break;}
Copy linkTweet thisAlerts:
@senshiNov 19.2004 — because it is outside the swittch scope.

to make the if work, it has to be between the Case ??: and the break; clauses, anything else is ignored
×

Success!

Help @mutimni spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...