RobG wrote:
> On Apr 24, 7:16 pm, Jason <[EMAIL PROTECTED]> wrote:
>> Hi everyone.
>>
>> I'm kind of stuck with a problem an I hope you can give me a hint on
>> how to solve it.
>>
>> I have a page with several (varying amount) checkboxes on it (called
>> memberemail). I have a script looping over all checkboxes, adding the
>> value (if selected) to a link.

[snip]

> Before people say "but you should be using Form.getElements()", try
> it, it's 3x slower than using $A(...).  In Safari[1] that's 9ms (plain
> js) versus 160ms (Prototype.js and Form.getElements) - the first
> Prototype run takes 1.5 seconds.  In Opera the plain js was 10x faster
> (6ms versus 61ms), again the first run took about 1.4 seconds.
> 
> Others are welcome to suggest faster ways.  If order is unimportant, a
> while loop might be faster in some browsers, a do loop might be faster
> still and maintain order - test thoroughly.

I'd be interested in seeing how using getElementsBySelector() performs (since on
some platforms it'll be using XPath which should be pretty fast). Also, someone
more CSS will probably correct my selector syntax.

    link='mailto:';
    var selector = 'input[type="checkbox" checked="true"]';
    $A($('memberemail').getElementsBySelector(selector).each(function (el) {
       link += el.value + ';';
    }

-- 
Michael Peters
Developer
Plus Three, LP


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to