63
votes
33answers
12k views

JavaScript - Are loops really faster in reverse…?

I've heard this quite a few times. Are JavaScript loops really faster when counting backward? If so, why? I've seen a few test suite examples showing that reversed loops are quicker, but I can't find ...
1
vote
2answers
115 views

For Loop in JavaScript - Lottery Website

I am trying to turn this code into a correct for loop statement, so that I can save my repetitions. I have tried my best to get it done, but I just don't know how I can write it correctly: function ...
1
vote
3answers
447 views

Do while javascript Problem

I'm trying to send multiple post within a do while loop but the result is not added <script type="text/javascript"> function action() { var initval = 1; var endval = 5; do { var ...
3
votes
2answers
474 views

In JavaScript, why is a “reverse while” loop an order of magnitude faster than “for”?

In these benchmarks, http://jsperf.com/the-loops, Barbara Cassani showed that a "reverse while" loop is way faster, while (iterations > 0) { a = a + 1; a = a - 1; iterations--; } ...
1
vote
3answers
410 views

jquery compare the height beneath img to h2's height

I am trying to adapt this: var h2=$('.block h2'); var divh=$('.block').height(); while ($(h2).outerHeight()>divh) { alert('enters while'); $(h2).text(function (index, text) { ...
1
vote
2answers
802 views

loop is too slow for IE7/8

I have a loop execution that needs to run in all browsers. in chrome/ff etc the execution runs fast and fine. in IE it's slow and end's up dispatching a prompt saying a script is running slow (no ...
0
votes
3answers
161 views

JavaScript while loop get select option and hide option from other select boxes

I'm trying to develop a football teamline function that will store up to 18 players (11 starting players and 7 subs) using a select box for each player. When a player is selected from one select box ...
0
votes
2answers
949 views

While loop in jquery of dynamic id and class

I have have multiple divs' with similar code within it, but also has a unique id within the main div that calls a toggleClass & slideToggle function. I'm trying to create a loop so that I do not ...
0
votes
3answers
983 views

javascript, while loop

i'm trying to get my script to wait for user input (click of a button) before continuing, this is v feasible in other languages, but seems impossible in js. basically, i want the user to select an ...
-1
votes
1answer
261 views

Apply php/MySql while loop in javascript object [closed]

I would like to take the following php/mysql loop, and apply the results: $test,$test1,$test2 to the var Data object in the javascript code. This will make the var Data dynamic, pulling its data to ...