473,839 Members | 1,467 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 1178
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
8000
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 ".load sos" and the command extension of SOS comes up when typing "!help". I assumed that SOS was loaded; however when issuing the command "!Threads". I got the following response "No valid SOS data table found" How can I solve this problem.
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 ".load sos" and the command extension of SOS comes up when typing "!help". I assumed that SOS was loaded; however when issuing the command "!Threads". I got the following response "No valid SOS data table found" How can I solve this problem.
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 ".load sos" and the command extension of SOS comes up when typing "!help". I assumed that SOS was loaded; however when issuing the command "!Threads". I got the following response "No valid SOS data table found" How can I solve this problem.
6
2446
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 the following problem: any suggestions? I have a newuser login page that creates a new SQL DB table record with login name and password then takes the user to the next (page) step in the registration setup. Currently the record is created in the...
0
9855
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10908
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10586
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10648
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10293
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7017
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4064
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.