var sw = true; var no = 0; function timer() { if (sw) { no++; } else { no--; } if(no > 14 || no < 1) { sw = ((sw) ? false : true); } var hex = no.toString(16).toUpperCase(); document.bgColor = '#FFFF' + hex + hex; document.getElementById('txtno').value = 'FFFF' + hex + hex; window.setTimeout('timer()', 500); } window.onload = function () { window.setTimeout('timer()', 50); }