Hello,
I would like to choose randomly some arrays out of my json.request (by
parameter)
How can i do this?

var number_to_choose = 3;

    var request = new Request.JSON({
                        url: path + 'recent.json',
                        onComplete: function(jsonObj) {
                                                                //var
rand = $random(0, jsonObj.lending_actions.length-1);
                                //addText(jsonObj.lending_actions[rand]);
                                addText(jsonObj.lending_actions);
                        }
                }).send();

        var addText = function(addArchiv) {

        zufall =$random(0,99);
        var name = new Element('h2', {'html': 'Hallo'});

                addArchiv.each(function(item, index) {
        if(index==zufall)
        {
                var liste = new Element('ul', {'class': 'recentlist'}).inject
(name);
        var el = new Element('li', {'html': 'index:'+index+' item:
'+item.id+'&nbsp;<a href="'+item.date+'"
class="loadMe">'+item.loan.use}).inject(liste);
        }
                });

        name.inject(sidebar);

        };

Reply via email to