JSbeginner1
12-09-2009, 01:00 AM
Hi, im new to this so i was wondering if anyone could tell me where im going wrong? im trying to get my switch statement to work and give me a specific reply for 4 names and if one of these names isnt typed into the promt box then i want an alert box to appear but i cant seem to get it to work. any ideas?
<body>
<script type="text/javascript">
//<![CDATA[
var Card_Suit;
Card_Suit=window.prompt("Think of a card suit? What suit are you thinking of?","????");
//]]>
</script>
<h1 style='color: blue'>Your Future In The Cards</h1>
<script type="text/javascript">
//<![CDATA[
switch(Card_Suit) {
case "clubs": {document.write("<p style='color: black'>");
document.write("Beware of three legged dogs crossing your path</p>");
}
break;
case "spades": {document.write("<p style='color: black'>");
document.write("Wear brown with pink spots for luck</p>");
}
break
case "hearts": {document.write("<p style='color: red'>");
document.write("You are going to meet a stranger with two heads</p>");
}
break;
case "diamonds": {document.write("<p style='color: red'>");
document.write("Your lucky number for today is 13,254,297</p>");
}
break;
}
else
window.alert("this is not a card");
}
<body>
<script type="text/javascript">
//<![CDATA[
var Card_Suit;
Card_Suit=window.prompt("Think of a card suit? What suit are you thinking of?","????");
//]]>
</script>
<h1 style='color: blue'>Your Future In The Cards</h1>
<script type="text/javascript">
//<![CDATA[
switch(Card_Suit) {
case "clubs": {document.write("<p style='color: black'>");
document.write("Beware of three legged dogs crossing your path</p>");
}
break;
case "spades": {document.write("<p style='color: black'>");
document.write("Wear brown with pink spots for luck</p>");
}
break
case "hearts": {document.write("<p style='color: red'>");
document.write("You are going to meet a stranger with two heads</p>");
}
break;
case "diamonds": {document.write("<p style='color: red'>");
document.write("Your lucky number for today is 13,254,297</p>");
}
break;
}
else
window.alert("this is not a card");
}