473,507 Members | 8,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SOS: Select box autochange script

1 New Member
Hi, everybody!
I'm trying to make this script - http://www.w3schools.com/php/php_ajax_database.asp
roll it's fields from the first to the last automatically
the code i have at the moment
Expand|Select|Wrap|Line Numbers
  1. function roller() {
  2. var total=3;//number of options
  3.  for (var i=0;i<total;i++) { 
  4.   setTimeout("roll("+i+")", (3000*(i+1)));
  5.  }
  6.  setTimeout("roller()", (3000*total));
  7. }
  8. function roll(i) { 
  9. document.usersform.users[i].fireEvent("onchange")
  10. }
  11.  
do not work an couse an error.
please, how make this work?
Feb 17 '08 #1
1 1157
wyatt
6 New Member
I believe that running setTimeout ends the current function. Instead, I suggest the following:

Expand|Select|Wrap|Line Numbers
  1. function roller(i) {
  2.     var total = 3;
  3.     var i = i : 0;
  4.     roll(i);
  5.  
  6.     setTimeout("roller("+((i+1)%total)+")",3000);
  7. }
  8.  
Essentially, each time, the function 'roller' is run, a value 'i' is passed to it, which increases by one every time the function runs. However, if it reaches the total, it rolls back to 0 (the '%' modulo operator). If you call roller without passing a value for 'i', it will default to 0.
Feb 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
7957
by: mich | last post by:
Hi I am trying to use Windbg with SOS.dll on VS 2003 by following the article "SOS:It's Not Just an ABBA Song Anymore" at http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslaye I tried the...
12
498
by: mich | last post by:
Hi I am trying to use Windbg with SOS.dll on VS 2003 by following the article "SOS:It's Not Just an ABBA Song Anymore" at http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslaye I tried the...
0
286
by: mich | last post by:
Hi I am trying to use Windbg with SOS.dll on VS 2003 by following the article "SOS:It's Not Just an ABBA Song Anymore" at http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslaye I tried the...
6
2433
by: dragiton | last post by:
ASP Code Redirect Error Hello I recently relaunched a website containing asp code which used to work perfectly. However, after resetting up the SQL DB and trying to work out some site bugs I have...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.