hello, how can i select and modify checkboxes with specified name part? ____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7907 from 19.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
$$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { c.checked = false; }); the name*=part_of_the_name will select any checkbox with ''part_of_the_name'' anywhere inside the checkbox. If you use name^will only check at the beginning, $= only checks at the end, and the equals sign only will match exactly the name you selected. Best, -Nicolas On 9/19/07, retacom-Mmb7MZpHnFY@public.gmane.org <retacom-Mmb7MZpHnFY@public.gmane.org> wrote:> > hello, > > how can i select and modify checkboxes with specified name part? > > ____________ > Virus checked by G DATA AntiVirusKit > Version: AVK 17.7907 from 19.09.2007 > Virus news: www.antiviruslab.com > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-19 17:46 UTC
Re: select and modifie checkboxes
HEllo, thanks. And how can i test if the first element selected or not selected? I want to toogle the selected and want to select/deselect this if the first entry is selected or deselected. name stands for the name attribute? is id possible?> $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { > c.checked = false; }); > > the name*=part_of_the_name will select any checkbox with > ''part_of_the_name'' anywhere inside the checkbox. If you use name^> will only check at the beginning, $= only checks at the end, and the > equals sign only will match exactly the name you selected. > > Best, > -Nicolas > > On 9/19/07, retacom-Mmb7MZpHnFY@public.gmane.org <retacom-Mmb7MZpHnFY@public.gmane.org> wrote: >> hello, >> >> how can i select and modify checkboxes with specified name part? >> >> ____________ >> Virus checked by G DATA AntiVirusKit >> Version: AVK 17.7907 from 19.09.2007 >> Virus news: www.antiviruslab.com >> >> >> > > >____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7910 from 19.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-19 18:08 UTC
Re: select and modifie checkboxes
and how can i get a list with th name and value/checked?> $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { > c.checked = false; });____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7912 from 19.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org wrote:> and how can i get a list with th name and value/checked? > > >> $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { >> c.checked = false; }); >>Try these (untested) functions below. - Ken var CheckboxTools = { toggle: function(seriesName) { var boxes = $$(''input[name="''+seriesName+''"]''); if (boxes.length) { var toState = !boxes[0].checked; boxes.each(function(box) { box.checked = toState; }); } }, getCheckedValues: function(seriesName) { return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, box) { if (box.checked) memo.push(box.value); return memo; }); } }; --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can use [id=myId] or #myId inside the selector. Check a CSS 3 selectors reference, and use the SelectORacle (http://gallery.theopalgroup.com/selectoracle/) to debug your selectors :) when you do $$(...).each(function(c) { ... }) the parameter passed to that anonymous function is the checkbox ("each" iterates over an enumerable passing every element to a function, read it on http://prototypejs.org/api/enumerable/each ). If you want to check whether the checkbox is already checked you can check the ''checked'' property on the checkbox (sic) //=> if (c.checked) { ... } If you want to find all checkboxes that are checked, you can use Enumerable.select: $$("input[type=checkbox]").select(function(c) { return c.checked }) Which will return the "filtered" array of all those items that return true on the iterator. Again, see the API at http://prototypejs.org/api/enumerable/select If you need to do something different for the first item, you can use the second (optional) argument passed to each/select/etc which is the current index. $$("input ....").each(function(checkbox, index) { if (index == 0) { // first checkbox } ... }); Best, -Nicolas On 9/19/07, retacom-Mmb7MZpHnFY@public.gmane.org <retacom-Mmb7MZpHnFY@public.gmane.org> wrote:> > and how can i get a list with th name and value/checked? > > > > $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { > > c.checked = false; }); > > ____________ > Virus checked by G DATA AntiVirusKit > Version: AVK 17.7912 from 19.09.2007 > Virus news: www.antiviruslab.com > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-20 14:50 UTC
Re: select and modifie checkboxes
Hello, hoe do i call this function? Sorry, the syntax is always a little new to me:)> retacom-Mmb7MZpHnFY@public.gmane.org wrote: >> and how can i get a list with th name and value/checked? >> >> >>> $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { >>> c.checked = false; }); >>> > Try these (untested) functions below. - Ken > > var CheckboxTools = { > toggle: function(seriesName) { > var boxes = $$(''input[name="''+seriesName+''"]''); > if (boxes.length) { > var toState = !boxes[0].checked; > boxes.each(function(box) { > box.checked = toState; > }); > } > }, > getCheckedValues: function(seriesName) { > return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, > box) { > if (box.checked) memo.push(box.value); > return memo; > }); > } > }; > > > > > > >____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7944 from 20.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-20 15:07 UTC
Re: select and modifie checkboxes
Hello, i change the code a little bit to var CheckboxTools = { toggle: function(seriesID) { var boxes = $$("input[type=checkbox][ID^="+seriesID+"]"); if (boxes.length) { var toState = !boxes[0].checked; boxes.each(function(box) { box.checked = toState; }); } }, getCheckedValues: function(seriesName) { return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, box) { if (box.checked) memo.push(box.value); return memo; }); } }; the toogle is working now:) For general . Is this a class and the toogle functions?> Try these (untested) functions below. - Ken > > var CheckboxTools = { > toggle: function(seriesName) { > var boxes = $$(''input[name="''+seriesName+''"]''); > if (boxes.length) { > var toState = !boxes[0].checked; > boxes.each(function(box) { > box.checked = toState; > }); > } > }, > getCheckedValues: function(seriesName) { > return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, > box) { > if (box.checked) memo.push(box.value); > return memo; > }); > } > }; > > > > > > >____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7945 from 20.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-20 15:29 UTC
Re: select and modifie checkboxes
Hello, i try th second function but get no result:( WHere is the boxs definition? var CheckboxTools = { toggle: function(seriesID) { // ID* = beinhaltet irgendwo, ID^ = nur am Anfang, ID$ nur am Ende var boxes = $$("input[type=checkbox][ID^="+seriesID+"]"); if (boxes.length) { var toState = !boxes[0].checked; boxes.each(function(box) { box.checked = toState; }); } }, getCheckedValues: function(seriesID) { return $$("input[type=checkbox][seriesID^="+seriesID+"]").inject([], function(memo, box) { if (box.checked) memo.push(box.value); return memo; }); } };>> and how can i get a list with th name and value/checked? >> >> >>> $$("input[type=checkbox][name*=part_of_the_name]").each(function(c) { >>> c.checked = false; }); >>> > Try these (untested) functions below. - Ken > > var CheckboxTools = { > toggle: function(seriesName) { > var boxes = $$(''input[name="''+seriesName+''"]''); > if (boxes.length) { > var toState = !boxes[0].checked; > boxes.each(function(box) { > box.checked = toState; > }); > } > }, > getCheckedValues: function(seriesName) { > return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, > box) { > if (box.checked) memo.push(box.value); > return memo; > });____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7945 from 20.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
retacom-Mmb7MZpHnFY@public.gmane.org
2007-Sep-20 18:07 UTC
Re: select and modifie checkboxes
Hello, some other problem:( This code works fine under firefox but it dosent select the checkbox under ie7. Somebody an idea?> > i change the code a little bit to > > var CheckboxTools = { > toggle: function(seriesID) { > var boxes = $$("input[type=checkbox][ID^="+seriesID+"]"); > if (boxes.length) { > var toState = !boxes[0].checked; > boxes.each(function(box) { > box.checked = toState; > }); > } > }, > getCheckedValues: function(seriesName) { > return $$(''input[name="''+seriesName+''"]'').inject([], function(memo, > box) { > if (box.checked) memo.push(box.value); > return memo; > }); > } > }; > >____________ Virus checked by G DATA AntiVirusKit Version: AVK 17.7950 from 20.09.2007 Virus news: www.antiviruslab.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Which function are you talking about? Use the :checked pseudo-class in getCheckedValues. (This also gets around the problem that you''re not initializing memo for each call, so you''ll get dirty data.) getCheckedValues: function(seriesName) { return $$(''input[name="''+seriesName+''"]:checked'').pluck(''value''); } ... and, you may want to try a lower-case "id" in toggle(). TAG On Sep 20, 2007, at 12:07 PM, retacom-Mmb7MZpHnFY@public.gmane.org wrote:> > Hello, > > some other problem:( This code works fine under firefox but it dosent > select the checkbox under ie7. Somebody an idea? > >> >> i change the code a little bit to >> >> var CheckboxTools = { >> toggle: function(seriesID) { >> var boxes = $$("input[type=checkbox][ID^="+seriesID+"]"); >> if (boxes.length) { >> var toState = !boxes[0].checked; >> boxes.each(function(box) { >> box.checked = toState; >> }); >> } >> }, >> getCheckedValues: function(seriesName) { >> return $$(''input[name="''+seriesName+''"]'').inject([], function >> (memo, >> box) { >> if (box.checked) memo.push(box.value); >> return memo; >> }); >> } >> }; >> >> > > ____________ > Virus checked by G DATA AntiVirusKit > Version: AVK 17.7950 from 20.09.2007 > Virus news: www.antiviruslab.com > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---