Page 1 of 1

Help with javascript homework

PostPosted: Sun Jan 24, 2010 3:33 pm
by MYKI
Complete the following:
2. Above closing </head> tag, insert an external script element that points to the functions.js file in the tutorial.02\case1 folder
Code: Select all
<script src="functions.js" type="text/javascript"></script>
</head>

3. Below this script element, insert another script element. Within the script element, declare two variables. The first variable is named seconds and will store the current elapsed time that the user has worked on the exam. The second variable is named clockld and will reference the commands used to repeatedly update the clock value. set the initial value of the seconds variable to 0. Do not set an initial value for the clockld variable
Code: Select all
<script src="functions.js" type="text/javascript"></script>
<script>
var seconds = 0;
var clockld;
</script>
</head>

4.( this is where i start to get lost. :x ) Create a function named runClock() that will update the time value in the Web page's clock. There are no parameters. Add the following command to the function:
a. Use a unary operator to increase the value of the seconds variable by 1
b. Change the value of the quizclock field in the quiz form to the value of the seconds variable
Code: Select all
<script src="functions.js" type="text/javascript"></script>
<script>
var seconds = 0;
var clockld;
</script>
<script>
function runClock(){
   thisSecond=.getSeconds()+1;
   thisMinute=.getMinutes();
   thisHour=.getHour();


}
</script>
</head>



Any help would be much appreciated. If you need any more information just ask, thank you

Re: Help with javascript homework

PostPosted: Sun Jan 24, 2010 4:10 pm
by Goatboy
For number two, make sure to understand the difference between absolute and relative URLs.

For number three, it looks like you did what they wanted, according to the instructions.

For number four, you will need to use a loop if it is supposed to constantly update the time (like a real clock) which seems like the case. Also, make sure you are updating the correct variables. Then you need to add in a way to write that value to the page.

This is all just going by the instructions you provided, so if the instructor wants something different, make sure to point it out.

Re: Help with javascript homework

PostPosted: Sun Jan 24, 2010 4:41 pm
by MYKI
Goatboy wrote:For number two, make sure to understand the difference between absolute and relative URLs.

For number three, it looks like you did what they wanted, according to the instructions.

For number four, you will need to use a loop if it is supposed to constantly update the time (like a real clock) which seems like the case. Also, make sure you are updating the correct variables. Then you need to add in a way to write that value to the page.

This is all just going by the instructions you provided, so if the instructor wants something different, make sure to point it out.



Well, all the files are all in one folder so that makes that easy
in 5 its asks to.
Create a function named startClock() that will start the web page clock and then repeadtedly update the elapsed time displayed in the clock. no parameters. Add the following commands:
a. Call the showQuiz() function to display the question in the online exam
b. Call the runClock() function every second, storing the ID of this timed-interval command in the clockld variable

inside of my runClock function i added
Code: Select all
function runClock(){
   thisSecond=.getSeconds()+1;
   thisMinute=.getMinutes();
   thisHour=.getHour();
document.buttons.quizclock.value = seconds;

}

I'm not sure if its working the timer still sits at zero


i really have no clue whats going on i missed the class and i have no clue what the teacher wants

Re: Help with javascript homework

PostPosted: Tue Jan 26, 2010 8:51 am
by tgoe
Teacher wants you to use setInterval (https://developer.mozilla.org/en/DOM/window.setInterval)