Click to See Complete Forum and Search --> : Anyone want to help?????


jolielady
04-02-2003, 02:50 PM
i really need help. I started this script but I'm missing someting and don't know how to finish it. This is my script

<html>
<head>
<title>JavaScript Generated Page</title>


<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="JavaScript">
var openingTag = null;
var closingTag = null;

var firstName = prompt ("Please enter your first name.","First Name");

var lastName = prompt ("Please enter your last name", "Last Name");

var size = confirm ("Click \"OK\" for large text. Click \"Cancel\" for small text.");
if (size == true) {openingTag = "<h1>"; closingTag = "</h1>";}
if (size == false) {openingTag = "<h6>"; closingTag = "</h6>";}

var color = prompt ("Please enter a color for the background: red, yellow, blue, purple, black, white, or green. Don't use capital letters or other colors.","Color");

var backcolor = prompt ("Please your favorite color: red, yellow, blue, purple, black, white, or green. Don't use capital letters or other colors.","Color");

</script>

</head>

<script language="JavaScript">
document.write("<body text=\"" + color + "\" bgcolor=\"" + backcolor + "\">");
</script>

<div align="center">
<script language="JavaScript">
document.write(openingTag + firstName + "<br>" + lastName + closingTag);
</script>
</div>

</body>

<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>

</html>


Of more, the arière-plan color will correspond to the preferred color of the netsurfer. Attention! The welcoming message must be the following one: « Hello, first name nomDeFamille, good morning (if it before noon), good afternoon (if it is between noon and 18 hours) or good evening (after 18 hours) ».

How can I do this.......:confused:

cgraz
04-02-2003, 03:04 PM
just grab the hour, then run an if statement to check if the hour is greater than 11. If that returns true, it's the afternoon. If it returns false, it's still morning.<html>
<head>
<title>JavaScript Generated Page</title>


<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

<script language="JavaScript">
var openingTag = null;
var closingTag = null;

var firstName = prompt ("Please enter your first name.","First Name");

var lastName = prompt ("Please enter your last name", "Last Name");

var size = confirm ("Click \"OK\" for large text. Click \"Cancel\" for small text.");
if (size == true) {
openingTag = "<h1>";
closingTag = "</h1>";
}

if (size == false) {
openingTag = "<h6>";
closingTag = "</h6>";
}

d = new Date();
hour = d.getHours();

if(hour > 11) {
timeofDay = "good afternoon";
} else {
timeofDay = "good morning";
}

var color = prompt ("Please enter a color for the background: red, yellow, blue, purple, black, white, or green. Don't use capital letters or other colors.","Color");

var backcolor = prompt ("Please your favorite color: red, yellow, blue, purple, black, white, or green. Don't use capital letters or other colors.","Color");

</script>

</head>

<script language="JavaScript">
document.write("<body text=\"" + color + "\" bgcolor=\"" + backcolor + "\">");
</script>

<div align="center">
<script language="JavaScript">
document.write(openingTag + "Hello, " + firstName + " " + lastName + ". " + timeofDay + closingTag);
</script>
</div>

</body>

<script language="JavaScript">
<!--

window.open = SymRealWinOpen;

//-->
</script>

</html>
Cgraz

jolielady
04-02-2003, 03:11 PM
You're a sweat heart. Perfect. I really did not think about this. You know I'm a newbee in the javascript. So I learn. I'll let you know my score for this homework. Again a big big thanks

:D

cgraz
04-02-2003, 03:38 PM
I'm a newbie to js also. You just have to get used to coming up with the logic behind things. Luckily I have a PHP background, but as of now, javascript is unchartered water for me. ;)

Cgraz