Hello,
I am new to these forums and very, very new to JavaScript. I am taking a class this semester at our local community college on JavaScript. We are using the book " Essentials for design, JavaScript Comprehensive" by Michael Brooks as well as a web site (mounted on Blackboard) on JavaScript design by our instructor. Basicly all the website involves is pull down menus with samples of code and no explanations. For me, there is no logic behind it and I really like to know what I am writing when I am writing code. So now to why I am so desperate....I have two projects I am working on that on due ASAP (actually they are probably overdue by now) but I can't seem to get them to work. At this point, I am totally confused as to what I am writing and the more I work on them the more confused I get....my instructor just refers me to the website which is making no sense to me. So I would like to know if anyone can please help me out here and if you can give me any help, please offer some explanations as to where I went wrong so I can learn and not make the same mistake again.
Project 1...we are suppose to complete a web page provided. Add functionality by giving the function a name, create a variable that instantiates a new date variable, create a variable that gets the date from the variable previously created, add a conditional to the IF statement that checks to see if the variable created is equal to 1, create a single line statment block that opens a new window with the to following information (window source url,
http://www.ibm.com, window name - quiz2, options - width 400, height 200), add an alert command that displays the follwoing message in case the day is not Monday, add the appropriate event handler to the input tag to call the user defined function. No paramenters are passed to the function.
Here is the original code the instructor gave us to work with:
<html>
<head><title>Quiz 2</title>
<script language="javascript">
function function_name(){ //replace function_name with a valid function name
var variableName = ??; //finish the var statement to create a new Date variable
var variableName = variableName.method; //finish the var statement to extract the day of the Week from the Date variable above
if(conditional){ //add a conditional that checks to see if the day of the week is Monday
Open a new window showing IBM’s site
}
else{
Display the message in an alert box
}
}
</script>
</head>
<body>
<input type="button" name="dispbutton" value="Display IBM" event handler to call the function in line 4 to display the IBM site in a new window>
</body>
</html>
Here is what I have managed to do...if I take out the If/Else statement the pop up works but if I leave that statement in nothing happens....so where did I go wrong.
<html>
<head><title>Quiz 2</title>
<script language="javascript">
myPopUp= window.open("
http://www.ibm.com", "myPopUp")
var currentTime = new Date();
var specificDate = new Date();
if(specificdate == 1){
window.open("
http://www.ibm.com", "quiz2","width=400","height="200");
}
else{
alert ("Today is not Monday. Please try again as soon as it is Monday.");
}
</script>
</head>
<body>
<input type="button" name="dispbutton" value="Display IBM" onClick = "window.open">
</body>
</html>
Thanks for any and all help with this,
Mary Anne