alerts - Minor Javascript Puzzle -


in bit of javascript, idea count forward clicks, until reach '5'; should go back.

count=0; function remote(w) {     count++;     if (count < 5 ) {         (var i=1;i<=5;i++) {             var g = document.getelementbyid("searchme").value = w+count;         }     }else if (count > 4) {          (var i=5;i > 0;i--) {             //alert(i);             var q = document.getelementbyid("searchme").value = w+count;         }     } } 

however, works if there alert. how 'i' value form, or so?

oh, quick response, all. prompted me work out something:

var f = 0; var s = 0; function updown() {     if (s < 5 && f==0){         countup('no.');         if (s==5){f=1}     }else if(s > 0 && f==1){         countdown('no.');         if (s==0){f=0}     } }  function countup(w) {     s++;     var el = document.getelementbyid('box03').innerhtml = w+s; }  function countdown(w) {     s--;     var el= document.getelementbyid('box03').innerhtml = w+s; } 

all javascript (other web workers) on web synchronous -- while js running browser can't else - including painting. reason see update when alert dialog comes because various mechanisms in browser make work require them repaint main window.

if want able show 1, 2, 3 .. etc you'll need use timeout.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -