开发者

automatically pick random select choices in web form

I have a page with a bunch of radio fields. How can I create a script that will loop through each select group and pick a开发者_运维技巧 random choice from each.

I already have sections of the site implemented with scriptaculous, which has known jquery compatibility issues.


Something like this should work with Prototype / Scriptaculous:

$$('select').each(function(item){
    item.selectedIndex = Math.floor(Math.random() * (item.length - 1));
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜