View Full Version : SOS: Form SelectedIndex autochange script

02-14-2008, 03:57 PM
im actually not an js coder, so i spent a few hours to find script i need but looks like there are no such script
i currently use this stuff -
so what i need is to make that fields in the box go automatically from first to the last then first again and so on until i choose some field manually.
i tried things like this

function roller() {
for (i=0;i<3;i++) { setTimeout("roll(i)", 3000) }
function roll(i) { document.usersform.users[i].selected = "1" }

but it jumps to last field and do not show any of previuos fields. and its do not affect mysql select action so nothing is really happens.
so, is there are any chances to expand that script this way?
thanks in advance

02-14-2008, 08:19 PM
your setting all three checkboxes to be checked at the same time. try this:
Note: If edited incorrectly, this script will cause the browser to stop responding, force the user to end the browser by force, and cause many people to get angry.

function roller() {
var total=3;//number of options
for (var i=0;i<total;i++) {
setTimeout("roll("+i+")", (3000*(i+1)));
setTimeout("roller()", (3000*total));
function roll(i) {
document.usersform.users[i].selected = "1";

02-15-2008, 11:41 AM
yea, thanks, its rolls now, but its still not affect function inside onchange event of the form, so nothing is happens, its strange couse i thought it should affect
and i have no idea how to stop this rolling

any ideas?

02-17-2008, 08:13 PM
ok, i find out why onchange handler of the form do not react on SelectedIndex change - its just can't be trigered this way, so i'm trying to use

instead of

document.usersform.users[i].selected = "1";
but its still don't work and couse an error, so
what is wrong now and how i can make it work?
please, anybody!