Help With Small Script

4 replies
Hi,

Right now I have a script that replaces i with a number.

It runs from whatever numbers I enter example it can run from 1 - 100.

I need the script to slow down though and not fly through all the numbers in like 10 seconds. I need to bascailly control the speed.

Here is my script.

var i=76563374

{

i=76563374

while (i<=76568374)

{
window.open("http://site.com?id="+ i +"",'mywindow','width=800,height=600,resizable=yes ,location=yes')

i=i+1

}

}

Again I'm not sure what I can ad in to control the speed of the numbers from going to fast.
#script #small
  • Profile picture of the author wayfarer
    To delay between each iteration, use setInterval, then clearInterval(id) when you've reached a certain number of iterations.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[4488171].message }}
  • Profile picture of the author butch04
    Hi sorry to be a pain but can you be more clear?

    I had someone else write this for me as I know very little java script.

    Thank You.
    Chris
    {{ DiscussionBoard.errors[4488473].message }}
  • Profile picture of the author wayfarer
    Ok, I thought you were learning. Learning requires reading documentation, seeing how things work, etc.

    So the actual script would look something like this:
    Code:
    var i = 76563374;
    var delay = 1000;//in milliseconds, 1000 = 1 second
    
    var id = setInterval(function() {
        window.open("http://site.com?id="+ i +"",'mywindow','width=800,height=600,resizable=yes ,location=yes');
        i++;
        if(i > 76568374) {
            clearInterval(id);
        }
    }, delay);
    If you don't have an engineer that can do this sort of thing for you regularly, you might want to consider learning a few basics. After all, this is very basic, fundamental stuff we're talking about here.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[4489128].message }}
  • Profile picture of the author butch04
    Thank you.

    I'm learning PHP as I use that more but from time to time use Java.

    I spent a good amount of my day searching Google for ways to make this work and tried a number of things with no luck so Warrior Forum was my last chance.
    {{ DiscussionBoard.errors[4493467].message }}

Trending Topics