Click to See Complete Forum and Search --> : Programming Error


XaieL
12-01-2003, 11:48 AM
Alright guys, it's problem time! Forgive my incompetence, but I have insomnia and have only had about 9 hours sleep in the past 21 days, plus the fact this is only my second Javascript program I've ever tried to make.

Anywho, I'm not sure where the error is, or what else I have to put, Any implications or comments are welcome, Thanks :)

The program is supposed to prompt you for your name, and what month you were born, it then is supposed to display Which Sign you are.


<html>
<head>
<title></title>

<script language="Javascript">
<!--hide me
//get a name
var welcome = prompt("Welcome this site will find your astronomical sign!", "ok?")
var name = prompt("What's your name?", "")
var month = prompt("What month were you born?", "")
//horoscope
var aries = " , you are Aries and your zodiac is the Ram which is an Autumn constellation! ";
var taurus = " , your are Taurus and your zodiac is the Bull which is an Autumn constellation! ";
var gemini = " , your are Gemini and your zodiac is the Twins which is an Winter constellation! ";
var cancer = " , your are Cancer and your zodiac is the Crab which is an Winter constellation! ";
var leo = " , your are Leo and your zodiac is the Lion which is an Winter constellation! ";

//construct some longer strings
var enter_aries = name + aries;
var enter_taurus = name + taurus;

//make some fancy strings
var enter_aries = enter_aries.bold().italics().toUpperCase().fontcolor("green");
var enter_taurus = enter_taurus.bold().italics().toUpperCase().fontcolor("brown");
if ((month == "March" && welcome == "ok"))
{
document.writeln(enter_aries + "<br>");
}
if ((month == "April" && welcome == "ok"))
{
document.writeln(enter_taurus + "<br>");
}

var enter_gemini = name + gemini;
var enter_cancer = name + cancer;
var enter_leo = name + leo;
var enter_gemini = enter_gemini.bold().italics().toUpperCase().fontcolor("purple");
var enter_cancer = enter_cancer.bold().italics().toUpperCase().fontcolor("orange");
var enter_leo = enter_leo.bold().italics().toUpperCase().fontcolor("blue");
if ((month == "May" && welcome == "ok"))
{
document.writeln(enter_gemini + "<br>");
}
if ((month == "June" && welcome == "ok"))
{
document.writeln(enter_cancer + "<br>");
}
if ((month == "July" && welcome == "ok"))
{
document.writeln(enter_leo + "<br>");
}




//stop hiding me-->
</script>
</head>
<body>
<h1>Horoscope</h1>

<script language="Javascript">
<!--hide me


</script>
</body>
</html>

Dennis
12-01-2003, 01:26 PM
i changed a bit what you did, what do you think about this?


<html>
<head>
<title></title>

<script language="Javascript">
<!--hide me
//get a name
var name = prompt("What's your name?", "")
var month = prompt("What month were you born (numer, from 1 to 12)?", "")

var phrases=new Array()
phrases[1]="Horospope for january";
phrases[2]="Horospope for february";
//go on up to december
write=name+", ";
for(i=1;i<13;i++){
if(month==i){
write+=phrases[i]
break;
}
}
document.write(write);


//stop hiding me-->
</script>
</head>
<body>
</body>
</html>