开发者

automatically pick random select choices in web form

开发者 https://www.devze.com 2023-02-12 22:03 出处:网络
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 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

精彩评论

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