Learning Loops & Want To Produce A Number Sequence
Aug 29, 2009
I have no js experience or coding experience of any kind other than the last few hours of reading a book called 'object-oriented javascript', and all was well until loops. firstly, this is how he teaches the while loop...
var i = 0;
while (i <10)
{i++;}
which results in 9 we move on to for loops...
var res ='';
for( var i = 0; i <10; i++)
{res += 'sometext' ;}
which repeats, but I'd like to be able to make that into a sequence of numbers... 123456789.
I have created a script that needs to constanstly poll a webpage, I do this with a controling function that fires off different functions to do the work, then restarts by calling itself after a second using settimeout.
on IE it runs forever, on firefox it stops after a while,
what am I doing wrong?
is there a limit on the number of times you can go around this type loop you can go around in firefox?
if there is a limit, how do I get around it?
Would it be freak out if the function is already running when it is fired again?
I'd like to know how I can produce an initial animation.I want animate a div automatically when the page is opened.I can animate my div associating the animation, for example, to a button or to a mouseover action, but i can't create an automatic animation.[code]
I learn OOP in javascript. and a few articles say that we can create a static prop/meth to an object just like a predefined object. But i think it just a prop/meth assingned to a constructor. Or is there really static meth/pro in javascript?.
how long did it take you to kearn Javascript to the point that you felt comfortable and confident! I am finding that I seem to be having a harder time with it than others! I have been learnig javascript for 4 years now and still find myself having trouble grasping the big picture?
I would think after so long one would know their way around the language what ever it maybe! I guess basically I would like to know if it is normal to be so confused about javascript?
I'm in the process of learning JavaScript. I picked up a "JavaScript for dummies" book at the library and it wasn't going too well. It was poorly written and made it difficult to understand things in the later chapter.
What is the best online resource to learning JavaScript? Preferrably one that is good at explaining format ( I often find myself wondering if certain aspects in my script need ()'s or a "=" sign).
For example, HTML has tags and that is what forms the mark up. I know JavaScript has multiple aspects (functions, objects), but I want an online resourcethat properly explains the format of these aspects.
I was wondering how to make URL...by Karl, work with an unordered lis instead of divs. I tried the below but did not work. I think what I have done here ('.links:visible');looks plain wrong (I can't put a class or an Id in there right??)[code]
When a thead contain less columns than real columns in the tbody section, the Tablesorter plugin produces a variable not found error in jquery coreTo reproduce simply do not put all <th> in thead that correspond to columns in tbody.
i am trying to do but I have no clue how to write it. Im trying to write a while loop that prints out all of the multiples of 5 between 10 and 95. I just need to know how to write the while loop i got everything else.
I'm my script I've three loops processing a very huge data file. IE & Firefox show a message box after some time saying my script could be infinite looping and give me a chance to stop it.
Is there a way to prevent this dialog box to show up? I'm writing a script used only on a intranet and the final customer should not see the message box.
So, out of that I would like to get 10 callme(1-10 or A-J) functions... I guess I am lost which way to build this with the placement & parsing of the variables.
Is it possible, when you have a loop in a loop, that when the inner loop reaches a certain point, it breaks out of both loops? For example:
[Code]....
The code above will break out of the (b=0;b<=10;b++) loop when b==5, but it will continue to do the a loop. not putting the first loop at all or making the first loop stop at 1): Is there a way to break out of both loops when the if condition is met? (I only ask that you not give a work-around because what I have in mind is much more complicated than this)
i'm scratching my head over achieving similar results with setInterval() function, and how I can keep it from looping infinitely.
I want to do something like this: var i = 0; var endTime = now + ((1000*60)*2); // 2 minutes after now while (now <=endTime) { i = i + 1; now = new Date().getTime(); } document.write("total iterations: " + i);
however you can't do this because of lag issues, so i'll settle for using setinterval on its smallest interval of a millisecond, here is my attempt to translate the above to a setinterval solution: var endTime = now + ((1000*60)*2); // 2 minutes after now var intervalID = setInterval(loopFunc(endTime),1); function loopFunc(endTime,intervalID) { if (new Date().getTime() <= endTime) { i = i + 1; } else { clearInterval(intervalID); }}
as you can see I have prolbems figuring out how to stop the interval from continuing to iterate, and passing the interval id, I'm clueless Also I'm clueless on echoing the total iterations via this method.
I want to get averages from a for loop. Let's say I had a # of exams and in that loop I wanted to add the exams up and calculate the average. How would I go about doing this? Is this even possible in a for loop?
I have 6 headers that are animated gifs. They transition, 3 of them left to right, the other 3 right to left.I would like to have them to change to next header in sequence no matter which page on my site they click.I'm not sure this can be done, but think javascript is my best bet. Can anyone point me in the right direction?
I want the images to change in sequence when the page is refreshed not random like i have below. Also I also need text to change on refresh to because I am going to have a descritption of the image below.
[CODE] <script type="text/javascript" language="JavaScript"> var imgs = new Array('<a href="VW_1.shtml"><img border=0 src="img/samples/VW/large_1.jpg" width=165 height=109" class="thumbnail_img">',