Help with javascript homework

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Help with javascript homework

Post by MYKI on Sun Jan 24, 2010 3:33 pm
([msg=33815]see Help with javascript homework[/msg])

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
MYKI
New User
New User
 
Posts: 8
Joined: Sun Jan 11, 2009 9:56 pm
Blog: View Blog (0)


Re: Help with javascript homework

Post by Goatboy on Sun Jan 24, 2010 4:10 pm
([msg=33819]see Re: Help with javascript homework[/msg])

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.
Assume that everything I say is or could be a lie.
User avatar
Goatboy
Expert
Expert
 
Posts: 2864
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: Help with javascript homework

Post by MYKI on Sun Jan 24, 2010 4:41 pm
([msg=33823]see Re: Help with javascript homework[/msg])

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
MYKI
New User
New User
 
Posts: 8
Joined: Sun Jan 11, 2009 9:56 pm
Blog: View Blog (0)


Re: Help with javascript homework

Post by tgoe on Tue Jan 26, 2010 8:51 am
([msg=33920]see Re: Help with javascript homework[/msg])

Teacher wants you to use setInterval (https://developer.mozilla.org/en/DOM/window.setInterval)
User avatar
tgoe
Contributor
Contributor
 
Posts: 716
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests