Nice, I'll try this!
Thanks a lot!

/z

On Apr 28, 1:23 am, kangax <[EMAIL PROTECTED]> wrote:
> I'll try to be careful this time.
>
> 1) Straight-forward way, only checks whether id starts with a string:
> var elements = $$('input[type="checkbox"][id^="match_this_"]');
>
> 2) A little more precise (based on regexp):
> var elements = $$('input[type="checkbox"]').findAll(function(el)
> { return /^match_this_\d$/.test(el.id) });
>
> Then:
>
> elements.shift().observe('click', function(e) {
>   elements.invoke('writeAttribute', 'disabled', e.target.checked);
>
> })
>
> - kangax
>
> On Apr 27, 6:40 pm, zoopzoop <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > I want to (as the topic suggests) get a list/array of all elements on
> > a page whose id starts with a string using Prototype.
> > For example, I have several checkboxes like this:
>
> > <input type="checkbox" id="match_this_1">
> > <input type="checkbox" id="match_this_2">
> > <input type="checkbox" id="match_this_3">
> > <input type="checkbox" id="match_this_4">
>
> > I want to find these elements on my page based on the fact that their
> > ids start with "match_this".
> > Then I want to assign a onclick-function to the first checkbox that
> > disables all the other ones.
> > Can somebody help me out with how to do this with Prototype?
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-spinoffs@googlegroups.com
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