Forum Moderators: open

Message Too Old, No Replies

how to adjust this minute string please

         

Simone100

12:32 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Hi, I am trying to call on a couple of objects where it keeps an object up for a minute before switching to a new object. Here is where I think my problem lies. The javascript error says "today" is undefined. I don't have any string in my code at all that says what "today" should be. Should I change this and get rid of "today" or should I define it? Will the following make something appear for a minute? It was all I could find. I am a little concerned about the "get minute" command as well. I don't want to get the time, I want something to appear for a certain amount of time. Hopefully someone knows what I should use instead to make something appear for a minute. Thanks!

var minutes = today.getMinutes();
{
var minutes = '1' + minutes;
}

RonPK

1:27 pm on Sep 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The method you need is setTimeout(code, ms);

Example:

setTimeout("alert('boo')", 60000);

That will show an alertbox after 60000 milliseconds (60 seconds).

Edit: getMinutes() works on a date object, which indeed needs to be defined first.

var today = new Date(); 
var minutes = today.getMinutes();

minutes should contain the minute portion of the current system time (30 over here).

[edited by: RonPK at 1:30 pm (utc) on Sep. 13, 2006]

Simone100

1:51 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



That was it! Thanks :) :) :)

Simone100

1:56 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



At least I think so, have to wait and see if it changes every minute.

var today = new Date();
var minutes = today.getMinutes();

That is the one that is working but not sure if switching every minute yet.

RonPK

2:11 pm on Sep 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want a piece of script to be executed at a set interval, you should use setInterval();

Example:

setInterval("myfunction()", 60000);

That will call myfunction() every 60 seconds.

Simone100

2:30 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



OK, but I am confused, which ones that I had before should I replace with that one, all of them? Thankya.

Simone100

2:30 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Replace the two that I had at the top with just that one?

RonPK

2:36 pm on Sep 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, you don't need getMinutes nor the Date object. Just use setInterval().

Simone100

2:39 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Replacing your function you used with the name of my own function probably, Thanks, I'll try it. I've been working on this for a couple months, would be nice to finally have it finished. Hoping.

Simone100

4:19 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Ron please check your webmaster inbox, I sent you a message, thank you.

Simone100

8:05 am on Sep 14, 2006 (gmt 0)

10+ Year Member



Thank you Ron~~~!

I was working on the looping problem when you sent that to me. I realized I didn't send you my looping examples.

Do you know why the

setInterval("minute_iframe()", 60000);

wouldn't work without your looping added in? Just curious.

As a sidenote, I almost had it working as well using this:
var today = new Date();
var minutes = today.getMinutes();
except it only changed by minute on page reload.

Thanks a lot!